Overview
Introduction
Most GeoJSON to KML converters try to preserve every possible KML feature, styling included, which adds a lot of surface area for something that's often just needed for a quick geometry export. This one deliberately doesn't.
Paste GeoJSON, get back straightforward KML XML: one Placemark per feature, named where a name property exists, geometry only, no styling.
What Is GeoJSON to KML Converter?
A hand-written GeoJSON-to-KML converter, since no KML-writing library is bundled with this tool. KML is a simple, well-documented XML format, so building it directly from a template is both easy to verify and easy to keep predictable.
It supports GeoJSON's Point, LineString, and Polygon geometries (outer ring only) directly, and flattens Multi* geometries into multiple Placemarks, one per member.
How GeoJSON to KML Converter Works
The pasted text is JSON.parse'd and checked for a FeatureCollection or Feature shape (a bare Feature is wrapped in a one-element FeatureCollection automatically), then each feature's geometry is matched against a small set of supported types.
For each feature, a <Placemark> element is built with an optional <name> from properties.name, followed by exactly one geometry element (Point, LineString, or Polygon with outerBoundaryIs only), all text content is XML-escaped before being embedded.
When To Use GeoJSON to KML Converter
Use this when you have GeoJSON geometry and need a quick, valid KML file for Google Earth or another KML-reading tool, without needing anything more than geometry and names to carry over.
It's not the right tool if you need polygon holes, per-feature styling, or icons preserved, those need a more elaborate KML writer.
Often used alongside KML to GeoJSON Converter and GeoJSON Viewer.
Features
Advantages
- Runs entirely client-side, your GeoJSON data never leaves your browser.
- Simple, predictable output: one Placemark per feature, easy to review and diff.
- Handles Multi* geometries by flattening them into multiple Placemarks rather than silently dropping them.
Limitations
- Polygon inner rings (holes) are not written to the output, only the outer boundary.
- No styling, icons, colors, or line widths are emitted, geometry and name only.
- GeometryCollection and any other unrecognized geometry type is skipped rather than converted.
Examples
Best Practices & Notes
Best Practices
- Add a name property to features you care about identifying, it's the only property this converter carries through to the output.
- If your polygons have holes, expect them to be simplified to just the outer boundary, and mention that when sharing the KML downstream.
- Check the reported feature/Placemark count against your source, a MultiPolygon or MultiLineString will produce more Placemarks than input features, which is expected.
Developer Notes
`convertGeoJsonToKml` in `geojson-to-kml-converter.ts` builds KML as a plain template string, `escapeXml` handles the three characters that matter for well-formed embedded text (&, <, >), and `geometryToPlacemarks` returns a `string[]` per feature (usually length 1, longer for Multi* geometries) so the caller can simply `.flatMap()` across all features to get the final Placemark list, no XML-building library involved.
GeoJSON to KML Converter Use Cases
- Exporting GeoJSON geometry from a web map or API into a KML file for Google Earth
- Converting a GeoJSON dataset's points/lines/polygons into KML for a client that only accepts KML
- Quickly checking what a GeoJSON FeatureCollection looks like translated into KML's Placemark structure
Common Mistakes
- Expecting polygon holes to survive conversion, only outer rings are written, this is a stated limitation, not a bug.
- Assuming styling (colors, icons) carries over from GeoJSON, there's no standard GeoJSON-to-KML styling mapping, so none is invented here.
Tips
- If you need styling in the final KML, add it by hand in a KML editor after conversion, this tool focuses on getting the geometry right first.
- Use GeoJSON Viewer beforehand to sanity-check the source geometry, so you know what to expect in the converted KML.