Working with KML and KMZ in Google Earth
December 2024 · 6 min read
KML (Keyhole Markup Language) was created by Keyhole Inc. — the company Google acquired to build Google Earth — and it has remained the native format for Google's mapping tools ever since. If you have ever received a file that opens in Google Earth, or exported a route from Google Maps, you have likely encountered KML or its compressed sibling, KMZ.
This guide covers everything you need to know to work with these formats effectively.
KML vs KMZ: what is the difference?
KML is a plain XML text file. Open one in a text editor and you will see XML tags describing placemarks, coordinates, styles, and folder structures. Because XML is verbose, KML files can get large for datasets with many features.
KMZ is simply a zipped KML file with the extension changed to .kmz. That is the entire difference. The compression typically reduces file size by 60–80%. KMZ files can also bundle referenced resources — embedded images, custom icons, or overlay images — alongside the doc.kml file inside the ZIP.
In practice: if someone sends you a .kmz file, you can rename it to .zip and extract it to find the doc.kml inside. If you need to share a KML by email or upload size is a concern, compress it to KMZ first.
Opening KML/KMZ in Google Earth
The simplest way to open a KML or KMZ file in Google Earth (desktop):
- Download and install Google Earth Pro (free)
- Double-click any .kml or .kmz file — Google Earth will open it automatically
- Alternatively, in Google Earth Pro: File → Open and browse to your file
The data appears in the "Places" panel on the left. You can toggle layers on and off, click individual placemarks to see popup descriptions, and navigate the 3D globe to your data.
For Google Earth in a browser (earth.google.com), click the menu icon (≡) → Projects → Open → Import KML file from computer.
Sharing KML via Google My Maps
Google My Maps is the shareable, collaborative cousin of Google Earth. It lets you publish a KML-based map as a URL that anyone can view in a browser — no Google Earth download required.
- Go to mymaps.google.com and click Create a new map
- Click Import in the layer panel
- Upload your .kml or .kmz file
- Google My Maps imports the placemarks and draws them on the map
- Click Share to get a URL or embed code
Note: Google My Maps has a limit of 2,000 features per layer and 10 layers per map. For larger datasets, consider GeoJSON with Leaflet.js or Mapbox GL JS instead.
KML structure: what is inside?
Understanding KML's structure helps when things go wrong. A minimal KML file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>My Data</name>
<Placemark>
<name>London</name>
<description>Capital of the UK</description>
<Point>
<coordinates>-0.1276,51.5074,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>Key elements to know:
<Placemark>— the equivalent of a feature. Can contain a Point, LineString, or Polygon.<Folder>— groups placemarks into logical sections (like layers in QGIS).<Style>— defines colours, icon images, label sizes.<ExtendedData>— stores arbitrary key-value attributes (like fields in a Shapefile).- Coordinates are always longitude, latitude, altitude (note: longitude first, which is the opposite of most people's intuition).
Common issues
KML not showing in Google Earth
If your KML loads but nothing appears on the map, the most likely cause is that the coordinates are in the wrong order (lat/lon instead of lon/lat), or the data is in a projected coordinate system instead of WGS 84. KML only supports WGS 84 (EPSG:4326).
Convert your data to WGS 84 first, then export to KML. Our converter handles this automatically via ogr2ogr's coordinate transformation.
KML has no attribute data
Some GIS tools export KML without attribute data, keeping only the geometry and name. If your converted KML is missing fields, try exporting via ogr2ogr or using Maparz — both preserve attributes as <ExtendedData> elements.
File is too large for Google My Maps
Google My Maps caps at 2,000 features and 5 MB. If your file exceeds this, either clip it to the relevant area before upload, or use Google Earth Pro (no size limit) or a web mapping library like Leaflet.
When to use KML and when to switch
KML is ideal when:
- You are sharing data with non-technical users who have Google Earth
- You need rich styling (custom icons, coloured polygons, labels)
- You are presenting a geographic story on Google My Maps
Switch to GeoJSON when:
- You are building a web map with Leaflet or Mapbox — JSON is far more convenient than XML
- Your dataset has more than a few thousand features (KML becomes slow to parse)
- You need to store rich attribute data without Google's 2,000-feature limit
Convert KML and KMZ files instantly
Convert KML or KMZ to Shapefile, GeoJSON, GeoPackage, or CSV. Free, no signup, GDAL-powered.