KML is the file format of Google Earth: an XML document that says what to draw on a globe and how it should look. It holds placemarks, paths, polygons, images laid over the terrain and the styles for all of them. You usually meet a KML file as an export from Google Earth or Google My Maps, as a download from an open-data portal, or as an attachment from someone who marked a plot, a route or a set of locations for you.
From Keyhole to an open standard
The K stands for Keyhole. Keyhole, Inc. developed the language for its Keyhole Earth Viewer. Google bought the company in 2004 and the viewer became Google Earth. Google then handed the format over to the Open Geospatial Consortium, which adopted KML 2.2 as an international standard on 14 April 2008. KML 2.3 followed in August 2015. Since then the official name is simply KML, and the format belongs to nobody in particular. Elements with the gx: prefix are Google's own additions, introduced with Google Earth 5.0 for tours and other features outside the standard.
What a KML file describes
GPX records where you were. KML describes a presentation. Its building blocks:
- Placemark: a named feature with a description, which may contain HTML, and a geometry:
Point,LineString(a path) orPolygon. - Folder and Document: the tree you see in the Google Earth sidebar.
- Style: icon, line colour and width, fill, label size. Styles are defined once and referenced by placemarks.
- GroundOverlay: an image, such as a scanned map, stretched over the terrain.
- NetworkLink: a pointer to another KML file on a server, so a small file can load live data.
- Time: a time stamp or time span on any feature, which drives the time slider.
Two details catch almost everyone who edits KML by hand. Coordinates are written as longitude, latitude, altitude, the reverse of what people type into a map search. Colours are written as aabbggrr: opacity first, then blue, green and red, the reverse of web colours. Altitude is in metres and optional.
KML and KMZ
A KMZ file is a ZIP archive with the KML document, by convention named doc.kml, plus the icons, photos and overlay images it uses. Send KMZ whenever the file refers to pictures. A bare KML carries only links to them.
How to open a KML file
- Google Earth on the web and on Android and iOS imports KML and KMZ. A local KML can be opened without signing in.
- Google Earth Pro on Windows, macOS and Linux opens it directly.
- Google My Maps imports KML and KMZ up to 5 MB unzipped.
- QGIS, the free GIS program, reads KML as a vector layer. GPXSee shows the points and paths.
- Phone, offline: Organic Maps imports KML and KMZ as bookmarks and tracks.
Common KML problems
KML points appear in the wrong place
Latitude and longitude are swapped. A point meant for New York, written as 40.71,-74.01, lands in Antarctica. The longitude comes first: -74.01,40.71.
KML won't import into Google My Maps
Check the size limit of 5 MB. My Maps also may not import some content at all: tours, time-based elements, image overlays, MultiGeometries, 3D models, folders and balloons with JavaScript.
Icons or images are missing
The KML only links to them. If the link points to a file on the author's computer, nobody else sees it. Ask for a KMZ.
KML won't open on a Garmin or in a route planner
Most GPS units and planners expect GPX. Garmin BaseCamp accepts KML and KMZ only as custom maps, that is image overlays, not as routes. Convert the file to GPX.
Converting KML
KML to GPX is the common direction. Our converter turns point placemarks into waypoints with their names, copies the description into the waypoint comment, and turns paths into tracks with elevation. A drawn path has no times, so the track has none either, and sports platforms will not accept it as an activity. Styles, the folder tree, polygons, image overlays and network links have no equivalent in GPX. From a KMZ, the KML document is read and the bundled images are left behind.
GPX to KML produces a document with a folder of waypoints and a folder of tracks. Each track is drawn as a semi-transparent line that follows the terrain, with one extra placemark per track point holding its time, altitude, speed and heading. Descriptions use feet and miles per hour. A long recording therefore becomes thousands of placemarks. Google Earth on the web caps an import at 10,000 map features and falls back to a read-only data layer above that. The details are on the GPX to KML page. Workouts in TCX can be converted to KML or KMZ as well.
KML at a glance
| Original developer | Keyhole, Inc., from 2004 Google |
|---|---|
| Standard | OGC KML 2.2 (14 April 2008), KML 2.3 (2015) |
| Type | XML text; KMZ is the same zipped with its images |
| Coordinates | longitude, latitude, altitude; WGS 84, metres |
| Stores | points, paths, polygons, styles, overlays, time, links to other files |
| Typical use | Google Earth and My Maps, sharing places and areas, open geodata |
Sources: Google's KML Reference, the OGC standard page, the Library of Congress format description and the My Maps import limits.