A KML file stores map locations and geographic data in a format that works across different mapping programs

KML stands for Keyhole Markup Language. It is a text-based file format that holds geographic information — points on a map, paths, shapes, and labels — in a way that mapping software can read and display. When you export locations from Google Maps, create a custom map, or share geographic data with someone else, you are often working with a KML file.

The file itself is plain text written in XML, which is a standard way of organizing information using tags. You can open a KML file in a text editor and see the actual code, but most people interact with KML files through mapping applications that translate that code into visual maps.

KML files typically have the extension .kml or .kmz (which is a compressed, zipped version of a KML file). They are useful when you want to save map data, share locations with others, or move geographic information between different programs.

Key Takeaways

  • KML files store map locations, routes, and shapes in a format that multiple mapping programs can read and display.
  • Google Maps, Google Earth, and many other mapping tools can open, create, and export KML files.
  • A KML file is plain text that you can view in any text editor, though mapping software makes it much easier to work with.
  • KML files are useful for saving custom maps, sharing locations with others, or transferring geographic data between different applications.

How KML files work

A KML file is structured like a recipe with ingredients and instructions. Instead of cooking directions, it contains geographic coordinates (latitude and longitude), place names, descriptions, and styling information like colors and icons. Each location or shape is wrapped in tags that tell the mapping software what it is looking at.

When you open a KML file in Google Maps or Google Earth, the software reads these tags and converts them into visual elements on the map. A point becomes a marker with a label. A series of connected points becomes a line or path. A closed shape becomes a polygon. The mapping program handles all the translation so you see a map instead of code.

The .kmz format is simply a KML file that has been compressed (zipped) to make it smaller and easier to share. When you download a KML file from the internet, it is often in KMZ format. Most mapping programs treat KML and KMZ files the same way — they decompress the KMZ automatically when you open it.

Common programs that use KML files

Google Maps is the most common place you will encounter KML files. You can export a custom map you created as a KML file, or import a KML file to view someone else's map. The process is straightforward: right-click on a map, select the export or download option, and choose KML as the format.

Google Earth also works with KML files and is often the preferred tool for viewing and editing them. Google Earth shows geographic data in 3D, which can be useful for seeing terrain, buildings, and spatial relationships. Many professional users and organizations use Google Earth to work with KML files because it offers more detailed visualization than Google Maps.

Other mapping and GIS (Geographic Information System) software also reads KML files, including ArcGIS, QGIS, and various specialized mapping tools. If you work with geographic data professionally, you may encounter KML files as a standard way to exchange information between different systems.

How to create and export a KML file

In Google Maps, you can create a custom map by clicking the menu button and selecting "Create a new map." As you add locations, draw routes, or add shapes, you are building the content that will go into a KML file. Once you are done, click the menu next to your map name and select "Download" or "Export," then choose KML as the file format.

In Google Earth, you can create placemarks (individual locations) and folders to organize them, then right-click and export the entire collection as a KML file. This is useful if you have built up a collection of locations over time and want to save or share them.

If you are working with geographic data from another source — a spreadsheet of addresses, a list of coordinates, or data from a survey — you may need to convert it to KML format. Some online converters can take a CSV file (comma-separated values) or other formats and produce a KML file. Alternatively, GIS software like QGIS can import various data formats and export them as KML.

How to open and use a KML file

The simplest way to open a KML file is to drag it directly into Google Maps or Google Earth. Both programs will recognize the file and display its contents on a map. You can also use the "Import" or "Open" option in these programs to browse for a KML file on your computer.

If someone sends you a KML file via email or a file-sharing service, download it to your computer, then open Google Maps or Google Earth and import it. The map data will appear immediately, and you can view, edit, or add to it.

If you want to view the raw code inside a KML file, you can open it with any text editor — Notepad on Windows, TextEdit on Mac, or any other plain-text editor. You will see the XML structure with tags like <Placemark>, <coordinates>, and <name>. This is useful if you need to edit the file directly or understand exactly what data it contains.

KML vs. other geographic file formats

KML is one of several formats used to store geographic data. Shapefile is another common format, especially in professional GIS work. Shapefiles are more complex and store data in multiple related files, while KML is simpler and self-contained. For basic mapping and sharing locations, KML is usually easier to work with.

GeoJSON is a newer format that stores geographic data in JSON, another standard text format. It is becoming more common in web-based mapping applications and programming. However, KML remains the standard for Google Maps and Google Earth, so it is still the most widely used format for casual mapping.

GPX (GPS Exchange Format) is designed specifically for GPS data like hiking routes and waypoints. If you are working with data from a GPS device or fitness tracker, GPX may be more appropriate than KML. However, many mapping programs can convert between these formats.

When you might need a KML file

If you are planning a trip and want to mark hotels, restaurants, and attractions on a map, you can create a custom Google Map and export it as KML to share with travel companions. They can import the file and see all your marked locations.

Real estate agents often use KML files to share property locations with clients. A list of homes for sale can be converted to a KML file and imported into Google Maps, making it easy for buyers to see all properties at once.

Researchers and organizations working with geographic data — environmental surveys, demographic information, or infrastructure mapping — use KML files to exchange data between team members and different software systems. A biologist studying wildlife migration patterns might export tracking data as KML and share it with colleagues.

If you manage multiple locations for a business, you can create a KML file with all your store or office locations, then share it with employees or customers so they can find you on a map.

Frequently Asked Questions

Can I edit a KML file after I create it?

Yes. In Google Maps, you can import a KML file and then edit the locations, routes, and shapes directly in the map editor. In Google Earth, you can modify placemarks and folders. You can also open a KML file in a text editor and change the code directly, though this requires understanding the XML structure.

What is the difference between KML and KMZ?

KML is the uncompressed format, and KMZ is a compressed (zipped) version of the same file. KMZ files are smaller and easier to share over email or the internet. Most mapping programs treat them identically — they automatically decompress KMZ files when you open them.

Can I open a KML file on my phone?

Yes. The Google Maps app on iOS and Android can open KML files. Download the file to your phone, then open it with Google Maps. Some other mapping apps also support KML, but Google Maps is the most reliable option across both platforms.

Is KML the same as a Google Map?

Not exactly. A Google Map is a map you create and store in your Google account. A KML file is a downloadable copy of that map's data. You can export a Google Map as a KML file, or import a KML file into Google Maps, but they are different things — one is cloud-based, the other is a file on your computer.

Can I convert a KML file to a different format?

Yes. Many online converters can take a KML file and output it as GeoJSON, Shapefile, GPX, or other formats. GIS software like QGIS can also import KML and export it in other formats. The specific steps depend on which format you need and which tool you use.