Overview
Introduction
Converts GeoJSON to KML XML: one Placemark per feature, named where a name property exists, geometry only.
Supports Point, LineString, and Polygon geometries. Polygon holes, styling, and icons are not carried over.
What Is GeoJSON to KML Converter?
A GeoJSON-to-KML converter that builds KML directly from a template rather than relying on an external library.
It handles GeoJSON's Point, LineString, and Polygon geometries (outer ring only), 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 in the browser; GeoJSON data is not uploaded anywhere.
- Predictable output: one Placemark per feature, easy to review and diff.
- Multi* geometries are flattened into multiple Placemarks rather than dropped.
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 other unrecognized geometry types are skipped.
Examples
Best Practices & Notes
Best Practices
- Add a name property to features you want identified in the output; it's the only property this converter carries through.
- If your polygons have holes, note that the output keeps only the outer boundary before sharing the KML downstream.
- Check the Placemark count against your source features: a MultiPolygon or MultiLineString produces more Placemarks than input features.
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.
- Assuming styling (colors, icons) carries over from GeoJSON: there's no standard GeoJSON-to-KML styling mapping, so none is generated.
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.