Overview
Introduction
KML is the XML format behind Google Earth and Google My Maps exports, but most web mapping libraries, geospatial APIs, and modern GIS tooling expect GeoJSON instead. This tool bridges that gap.
Paste or upload KML text and get back a pretty-printed GeoJSON FeatureCollection, converted entirely in your browser.
What Is KML to GeoJSON Converter?
A client-side KML-to-GeoJSON converter built on @tmcw/togeojson, a widely used, well-tested library for exactly this conversion, rather than a hand-rolled parser.
It reads KML's Placemark elements (points, lines, polygons and their multi-part variants) and produces the equivalent GeoJSON Feature for each one, wrapped in a single FeatureCollection.
How KML to GeoJSON Converter Works
The pasted or uploaded KML text is first parsed into an XML Document using the browser's built-in DOMParser, since @tmcw/togeojson operates on a parsed DOM tree, not raw text.
That Document is checked for a hidden parsererror element (DOMParser's silent way of reporting malformed XML) before being handed to the kml() conversion function, which walks the Placemark tree and builds a GeoJSON FeatureCollection.
When To Use KML to GeoJSON Converter
Use this whenever you have a KML export, from Google Earth, Google My Maps, or another GIS tool, and need GeoJSON for a web map, API, or another tool downstream.
It's also useful for simply inspecting what's inside a KML file, since GeoJSON's structure is often easier to skim than nested KML XML tags.
Often used alongside GPX to GeoJSON Converter, GeoJSON to KML Converter and GeoJSON Viewer.
Features
Advantages
- Runs entirely client-side, your KML data never leaves your browser.
- Built on a mature, well-tested conversion library rather than an approximate hand-rolled parser.
- Friendly error messages for malformed XML instead of a cryptic parser crash.
Limitations
- Doesn't support .kmz (zipped KML), only plain KML XML text.
- Highly KML-specific extensions (custom styling, network links, ground overlays) may not have a clean GeoJSON equivalent and can be dropped or simplified during conversion.
Examples
Best Practices & Notes
Best Practices
- If your source is a .kmz, unzip it first and feed the plain .kml file inside to this tool.
- Check the feature count after conversion against what you expect, a mismatch can point to unsupported KML elements being skipped.
- Pipe the output into GeoJSON Viewer to visually sanity-check the converted geometry before using it downstream.
Developer Notes
`convertKmlToGeoJson` in `kml-to-geojson-converter.ts` is a thin, defensively-wrapped call around `@tmcw/togeojson`'s `kml()`: it parses text to a `Document` via `DOMParser`, explicitly checks for a `parsererror` element (since `DOMParser` never throws), and only then calls `kml(doc)`, catching any unexpected conversion error so the component always gets a typed `{success, geojson?, error?}` result rather than a thrown exception.
KML to GeoJSON Converter Use Cases
- Converting a Google Earth or Google My Maps KML export to GeoJSON for a web map
- Feeding KML-sourced geometry into a GeoJSON-only API or geospatial pipeline
- Inspecting a KML file's contents in GeoJSON's more compact, easier-to-skim structure
Common Mistakes
- Uploading a .kmz file directly, this tool expects plain KML XML text, not the zipped format.
- Assuming custom KML styling (icons, colors, line widths) carries over, GeoJSON has no native styling concept so that information is dropped.
Tips
- If conversion fails, open the KML in a text editor and check for an unclosed tag near wherever the source was last hand-edited.
- Use the feature count shown after conversion as a quick sanity check against how many Placemarks you expect the source to contain.