The Short Answer
To convert KML to GeoJSON, pick one of three methods. Fastest: drag your .kml file into a free KML to GeoJSON converter and download the result — done in under a minute. Most control: open it in QGIS, right-click the layer, and export as GeoJSON. Most automatable: run a single ogr2ogr command from the GDAL toolkit. All three preserve your geometry; the online route is what most people need.
KML is Google Earth's format — great for viewing, clunky for web maps. GeoJSON is the web's native map format — lean, readable, and understood by every modern mapping library. Converting is usually a one-way upgrade, and this guide walks through each method so you can pick the right one for your file.
Method 1: Online Converter (Fastest)
For most people, most of the time, this is the answer. Here is the whole process:
- Open the converter. A free KML to GeoJSON converter that runs in your browser — nothing to install, no account needed.
- Drop in your .kml file. Drag and drop works, or click to browse. If you have a .kmz file (the zipped version of KML), unzip it first — most online converters want the .kml inside.
- Download the .geojson. The conversion happens on your machine in seconds for typical files. Save the result with a clear name, like trails-2026.geojson.
- Spot-check it. Open the result in a map viewer and confirm your placemarks, lines, and polygons all landed where they should.
This method shines for one-off conversions and files up to a few megabytes. Your data never leaves your browser, which makes it safe for anything you would not email to a stranger. The only real limit is file size — a 500 MB KML will choke a browser tab, and for that you want Method 2 or 3.
Method 2: QGIS (Best for Big Files and Batches)
QGIS is a free, open-source desktop GIS application — the closest thing the mapping world has to a Swiss Army knife. If you convert files regularly or work with large ones, it is worth the one-time install.
- Install QGIS from qgis.org (Windows, Mac, and Linux are all supported) and open it.
- Drag your KML into the Layers panel. QGIS reads it immediately and shows your data on the map.
- Right-click the layer, choose Export, then Save Features As. Pick GeoJSON as the format, choose where to save, and confirm the coordinate reference system is WGS84 (EPSG:4326) — it usually is by default for KML.
- For many files at once, use the Batch mode in the same export dialog, or the "Convert format" tool in the Processing Toolbox to queue up a whole folder.
The payoff for the extra setup: QGIS handles enormous files without breaking a sweat, lets you preview and clean your data before converting, and gives you fine control over things like coordinate precision and which attributes to keep. If KML-to-GeoJSON is a weekly task for you, this is your method.
Method 3: Command Line With ogr2ogr (Best for Automation)
If you live in a terminal, or you need to convert files as part of a script, ogr2ogr is the tool. It ships with GDAL, the open-source geospatial library that quietly powers half the mapping software on Earth. Install GDAL from gdal.org or through your system's package manager.
The basic conversion is one command: ogr2ogr with the GeoJSON output format flag, your output filename, and your input file. In plain terms, you tell it "make me GeoJSON from this KML" and it does exactly that, printing nothing on success — silence means it worked.
Where this method earns its keep is repetition. Need to convert 200 KML files every Monday morning? A three-line shell loop does it before your coffee cools. Need it inside a data pipeline? ogr2ogr slots right in. It also exposes useful options, like limiting coordinate precision to keep file sizes down — handy when your source has 15 decimal places nobody needs.
What Survives the Trip (and What Does Not)
Conversion is not photocopying — the two formats think about maps differently. Here is what to expect:
- Geometry survives perfectly. Points, lines, and polygons come through with coordinates intact. This is the part that matters most, and it is lossless.
- Attributes mostly survive. Names, descriptions, and custom data fields in your KML usually become properties in the GeoJSON. Check a feature or two afterward to confirm the field names came through cleanly.
- Styling does not survive. KML can carry icon choices, line colors, and fill styles. GeoJSON has no standard way to store styling, so colors and custom icons get left behind. If styling matters, you will reapply it in your web map afterward.
- Network links, tours, and 3D models do not survive. KML features like fly-through tours, linked external files, and 3D buildings have no GeoJSON equivalent. The geometry converts; the extras do not.
- Folder structure flattens. KML folders become a flat list of features. If your KML used folders as categories, that grouping info may live on only as an attribute — or not at all.
None of this is a flaw in any converter. The formats simply have different jobs: KML is a presentation format, GeoJSON is a data format.
KMZ Files: Unzip First
A quick detour, because this confuses people weekly: a .kmz file is just a .kml file inside a ZIP archive (Google Earth uses KMZ to bundle the KML with its images). Most converters accept .kml only.
The fix takes ten seconds: rename the file from .kmz to .zip if your system needs the hint, double-click to unzip, and grab the .kml inside — usually called doc.kml. Then convert that. Some desktop tools accept KMZ directly, but when in doubt, unzip first and remove one variable from the equation.
Checking Your Work
Never trust a conversion you have not looked at. The check takes a minute:
- Validate the GeoJSON. Run it through a GeoJSON validator to confirm the structure is legal. A clean pass means any tool can read it.
- View it on a map. Load it in a KML/GeoJSON viewer next to the original KML if you can. Every placemark should sit exactly where it did before.
- Count features. If your KML had 150 placemarks, your GeoJSON should have 150 features. A mismatch means something got dropped or merged.
- Inspect attributes. Click a few features and confirm names and descriptions came through. Encoding hiccups — odd characters where accented letters should be — show up here first.
When to Convert to GPX Instead
GeoJSON is the right target for web maps, but not for everything. If your destination is a handheld GPS unit, a fitness watch, or a backcountry navigation app, you probably want GPX instead — it is the format GPS hardware speaks natively.
The decision is simple: web map or database → GeoJSON; GPS device or hiking app → GPX. A KML to GPX converter handles the second case the same effortless way. Converting KML to GeoJSON and then wondering why your Garmin will not read it is a common wrong turn — pick the target format for the tool that will consume it.
Troubleshooting Common Problems
- Empty output file. The KML likely uses a network link (data fetched live from a URL) rather than embedded coordinates. Download the linked data first, or open the KML in Google Earth and save a local copy.
- Weird characters in names. An encoding mismatch. Make sure the output is saved as UTF-8 — most converters do this by default, but files from older Windows software sometimes need a nudge.
- Huge output file. KML from GPS traces can carry far more precision than anyone needs. Rounding coordinates to 6 decimal places (about 4 inches of precision) often shrinks files dramatically with zero visible change.
- Polygons that will not fill. The ring direction or closure may have gotten mangled. Validate the file — the validator flags unclosed rings specifically — and fix or re-export.
- Browser tab freezes. Your file is too big for the online method. Switch to QGIS or ogr2ogr, which stream data instead of holding it all in memory.
Before You Convert: A 60-Second Prep Checklist
Conversions go wrong most often because of the input, not the tool. Run through this checklist before you convert and you will avoid nearly every common failure:
- Confirm it is really KML. Open the file in a text editor and check that it starts with XML and contains a kml tag. Files renamed to .kml that are actually GPX, CSV, or something else will convert to garbage or nothing.
- Check for network links. Search the file for the words NetworkLink or Link with an href. If your KML pulls its data live from a web address instead of containing coordinates, converters will produce an empty file. Open it in Google Earth and save a local copy first.
- Note the size. Under 10 MB? The online converter will be instant. Over 100 MB? Go straight to QGIS or ogr2ogr and skip the browser entirely.
- Decide what you need to keep. If attribute data (names, descriptions) matters, verify after conversion that the fields survived. If styling matters, accept now that you will rebuild it — no converter preserves KML styles in GeoJSON.
- Save the original. Keep an untouched copy of the KML before converting. If anything looks off in the GeoJSON, you want a clean source to re-convert rather than trying to repair the output.
A minute of prep here saves the classic loop of convert, discover a problem, guess at the cause, and convert again.
Going Back: GeoJSON to KML
Conversion is not always a one-way street. Plenty of people need to turn GeoJSON back into KML — usually because someone else in the chain lives in Google Earth. A county planner might publish data as GeoJSON for the web, then need a KML version for a colleague who only opens Google Earth Pro. A hiking club might keep its trail database in GeoJSON, then export KML for members' phones.
The good news is that every method in this guide runs in reverse. The same free GeoJSON to KML converter handles the online route: drop in the .geojson, download the .kml. In QGIS, right-click the GeoJSON layer and export as KML instead. With ogr2ogr, you swap the format flag and the filenames, and the command reads almost identically.
Two things to expect on the return trip. First, your attributes come back as KML description balloons and extended data — readable, but formatted Google's way rather than yours. Second, this is your chance to add styling, because KML actually supports it: set line colors, icon styles, and folder structure in Google Earth after converting, then save. The styling lives in the KML from that point on, even though the GeoJSON never carried it.
One caution: round-tripping — KML to GeoJSON to KML — is safe for geometry but lossy for everything else. Each hop drops whatever the target format cannot express. If you find yourself converting back and forth repeatedly, pick one format as the master copy and generate the other from it instead of chaining conversions. Your data will thank you.
Pick Your Method and Go
One file, normal size, need it now? Use the free online KML to GeoJSON converter and be done in a minute. Big files or weekly batches? Install QGIS once and never think about it again. Building a pipeline? ogr2ogr is waiting in your terminal.
Whichever you choose, validate the result and glance at it on a map before you ship it. Two minutes of checking beats an afternoon of debugging a map that renders the wrong thing in the wrong ocean.
