KML to GeoJSON: Best Practices and Common Mistakes
To convert KML to GeoJSON cleanly, export plain KML rather than KMZ, trust the mandated [longitude, latitude] coordinate order, and plan ahead for how folders and polygon holes carry over. These are the details that separate a conversion that just works from one that silently drops data or crashes a web map. This is a best-practices reference for developers and analysts who already convert files and want fewer surprises.
Export the right file in the first place
Most conversion failures happen before conversion. Two habits prevent them:
- Save as KML, not KMZ. KMZ is a zipped archive containing a
doc.kml. A converter that expects raw XML can't read the zip directly. In Google Earth choose "Save Place Asβ¦" and pick the.kmlextension. If you only have a KMZ, rename it to.zip, unzip, and convert the innerdoc.kml. - Clean up before you export. Delete empty folders, temporary placemarks and image overlays you don't need. GeoJSON has no concept of overlays or screen graphics, so exporting them just produces noise you'll strip out later.
The coordinate-order trap
The most damaging mistake in the entire workflow is hand-swapping coordinates. The GeoJSON spec (RFC 7946) mandates [longitude, latitude] β the opposite of how humans say "lat, long," but the same order KML already uses in its lon,lat,alt tuples. So a correct converter never flips anything.
Libraries like Leaflet expect [lng, lat] in GeoJSON and flip to lat/lon internally. If you "fix" the order by hand, your points land in the wrong hemisphere or the ocean.
Rule of thumb: if your converted points appear off the coast of West Africa near 0Β°,0Β°, or mirrored across the equator, someone swapped the axes. Pass the GeoJSON through as-is and let the mapping library handle presentation.
Preserving structure: folders, holes and MultiGeometry
KML carries organizational and geometric detail that GeoJSON models differently. Knowing how each maps prevents lost data.
| KML construct | GeoJSON result | Watch out for |
|---|---|---|
| Folder | folder property on each feature | GeoJSON has no folders β filter by the property to regroup |
| Polygon innerBoundaryIs | Extra ring (a hole) | Don't discard inner rings; donuts and lakes need them |
| MultiGeometry | GeometryCollection | Some strict tools dislike mixed-type collections |
| name / description | Feature properties | Style-only ExtendedData may not survive |
A frequent oversight is assuming folders vanish. They don't have to β this converter writes each enclosing folder's name into a folder property, so you can filter or group by it in QGIS, Leaflet or your own code to rebuild the original hierarchy.
Validate before you ship
KML from My Maps and older Earth versions can contain quirks β namespaces, CDATA-wrapped HTML descriptions, or styling that doesn't translate. After converting, do two checks: confirm the output is valid GeoJSON with a validator, and eyeball the feature count against the number of placemarks you expected. If a description was rich HTML, remember it becomes a plain property string, so escape or sanitize it before rendering in a popup. And because everything here is parsed by your browser's own XML engine, private property boundaries and site plans never leave your machine during any of this.
Try the KML to GeoJSON Converter β free and 100% in your browser.
FAQ
My converted points are in the wrong place β what happened?
Almost always a swapped coordinate order. GeoJSON requires [longitude, latitude]; if you or an intermediate step flipped it to [latitude, longitude], everything shifts. Use the converter's output unchanged and let your map library handle display.
Why won't my KMZ file convert?
KMZ is a zip archive, not XML. Rename it to .zip, extract the doc.kml inside, and convert that file. The geometry converts identically once you reach the raw KML.
Will I lose my Google Earth folder organization?
No, if the converter preserves it. Each feature gets a folder property holding its enclosing folder's name, so you can filter or group by that attribute to recreate the structure GeoJSON itself can't store.
Do polygon holes survive the conversion?
Yes. A KML outerBoundaryIs becomes the first GeoJSON ring and each innerBoundaryIs becomes an additional ring β exactly how GeoJSON represents holes, so donut zones and lakes stay intact.
Related free tools
- GeoJSON to KML Converter β convert back for Google Earth.
- GPX to KML Converter β bring GPS tracks into the KML world.
- JSON Formatter β pretty-print and inspect the output.
- XML Validator β check source KML before converting.
Built by ByteVancer
ByteTools is a free product of ByteVancer, a software and web development studio building web apps, SaaS and custom software. If you're building a mapping app or a data pipeline that needs reliable format conversion, explore how ByteVancer can help.
Recommended reading
How to Convert KML to GeoJSON for Web Maps
Convert KML from Google Earth to a clean GeoJSON FeatureCollection in your browser. Placemarks, folders and polygons with holes supported β free, no upload.
KML to GeoJSON Use Cases: Real Web-Map Workflows
Real scenarios for converting KML to GeoJSON: migrating My Maps into apps, loading layers into QGIS and Leaflet, and feeding PostGIS, with worked examples.
XOR Cipher Use Cases: CTFs, Learning, and Puzzles
Real use cases for the XOR cipher, from CTF challenges and teaching bitwise logic to lightweight obfuscation, with concrete worked examples.
XOR Cipher Tips: Keys, Security, and Common Mistakes
Pro tips and common mistakes for the repeating-key XOR cipher: key length, reuse pitfalls, format choices, and when to switch to real encryption.