What Is a KML File? A Clear Guide to Google's Geographic Data Format
If you've ever downloaded a map layer, shared a custom route, or exported location data from Google Earth, there's a good chance you've encountered a .kml file — even if you didn't realize it at the time. KML files are the backbone of a huge amount of geographic data sharing, but they're not widely understood outside of GIS and mapping circles. Here's what they actually are and how they work.
KML Stands for Keyhole Markup Language
KML (Keyhole Markup Language) is an XML-based file format used to store and display geographic information — things like points, lines, polygons, images, and 3D shapes — within mapping software. The name "Keyhole" comes from Keyhole Inc., the company that originally developed the format before Google acquired it in 2004. Google then used it as the foundation for Google Earth, and in 2008 the format became an open international standard maintained by the Open Geospatial Consortium (OGC).
Because KML is built on XML, it's a plain-text format. If you open a .kml file in a text editor, you'll see structured tags describing coordinates, names, descriptions, styles, and rendering instructions — all human-readable, at least in principle.
What Kind of Data Does a KML File Hold?
KML files can contain a surprisingly wide range of geographic and visual data:
- Placemarks — pins or markers at specific coordinates, often with a name and description
- Paths and routes — sequences of coordinates forming lines (useful for roads, trails, or flight paths)
- Polygons — enclosed shapes defining areas like neighborhoods, regions, or property boundaries
- Ground overlays — images stretched over a specific area of the map
- Network links — references to external KML or data feeds, allowing dynamic or live data layers
- 3D model references — used in Google Earth to render buildings or terrain features
Each element can carry metadata: names, descriptions, timestamps, altitude information, and custom styling like color, line weight, and icon selection.
KML vs. KMZ: What's the Difference?
You'll often see both .kml and .kmz as file extensions in the same context. They're closely related:
| Feature | KML | KMZ |
|---|---|---|
| Format | Plain XML text | Compressed ZIP archive |
| File size | Larger | Smaller |
| Contains images/icons | No (references external files) | Yes (bundles assets inside) |
| Portability | Lower | Higher |
| Editing | Easy in a text editor | Requires unzipping first |
KMZ is essentially a zipped version of a KML file, often bundled with any supporting assets like custom icons or image overlays. When portability matters — sharing a map layer with someone else, for instance — KMZ is typically preferred because everything travels together in one file.
Where Are KML Files Used? 🗺️
KML was popularized by Google Earth but has spread well beyond it. Common applications include:
- Google Maps — users can import KML files to display custom layers on top of standard maps
- Google Earth Pro — the primary native format for saved places and tours
- QGIS and ArcGIS — professional GIS platforms that accept KML as one of many import/export formats
- GPS devices and apps — some navigation tools accept KML to define waypoints or routes
- Government and environmental data — agencies frequently publish KML files for public data like flood zones, zoning maps, and utility infrastructure
- Journalism and data visualization — reporters and researchers use KML to build geographic storytelling layers
The format's open standard status means nearly any serious mapping tool has some level of KML support, though the depth of that support varies considerably.
How KML Files Are Created
You don't need to write XML by hand to create a KML file. Common creation methods include:
- Google Earth Pro — draw placemarks, paths, and polygons visually, then export as KML or KMZ
- Google My Maps — create custom maps in a browser and download as KML
- GIS software — export from QGIS, ArcGIS, or similar tools in KML format
- Programmatic generation — developers often generate KML files from databases or APIs, since it's just structured text
- GPS data export — some GPS devices and apps can export recorded tracks as KML
The relative simplicity of the XML structure makes KML a common output target when building location-aware applications.
The Variables That Affect How Useful KML Is for You
KML is a well-established standard, but how well it serves your needs depends on several factors:
Software compatibility — Not all platforms render KML identically. Styling attributes that display perfectly in Google Earth may be ignored or interpreted differently in another tool.
File complexity and size — A KML file with thousands of polygons or network-linked live feeds will behave very differently than a simple file with ten placemarks. Performance can degrade noticeably in browser-based tools with large files.
Altitude and 3D data — KML supports altitude modes (clamped to ground, relative to ground, absolute), but not every application renders the third dimension. A file built for Google Earth's 3D environment may look flat in a 2D web map.
Coordinate precision — KML stores coordinates as decimal degrees. For most general mapping this is fine, but highly precise engineering or surveying work may require formats with stricter precision controls.
Live vs. static data — KML's Network Link feature allows files to pull live data from a URL, which is powerful but requires server infrastructure and ongoing maintenance. A static KML is far simpler to manage.
KML's Place in the Broader Data Format Landscape
KML isn't the only geographic data format — far from it. GeoJSON has become popular for web development due to its native fit with JavaScript. Shapefiles remain common in professional GIS environments. GPX is the standard for GPS track data. TopoJSON handles topology-aware mapping efficiently.
KML's strengths are its readability, its rich styling options, its deep integration with Google's mapping products, and its open standard status. Its weaknesses include a larger file size compared to formats like GeoJSON, and the fact that some advanced styling features are implementation-specific rather than universally supported.
Whether KML is the right format for a given project depends heavily on which tools you're using to create, edit, and display the data — and what level of styling and interactivity you actually need.