Free KML test files and sample generator
The XML format Google Earth and most mapping tools use for placemarks, paths and polygons. Generate valid .kml sample files to test geospatial imports and map rendering.
What is a .kml file?
KML: Keyhole Markup Language. KML is the XML that Google Earth introduced and most mapping software now reads, describing places rather than routes. A Placemark can hold a point, a path or a polygon, and each is handled differently by a renderer, a point becomes a pin, a polygon becomes a shaded area with a boundary that must close back on itself. That variety is why a single sample file rarely exercises an importer properly.
Why generate a test KML file?
- Test a geospatial import, map overlay or GIS pipeline.
- Exercise points, paths and polygons, which render along different code paths.
- Check coordinate ordering, KML writes longitude before latitude, a classic source of bugs.
What you can put inside a .kml file
You get 3 content options for KML, so the file holds something meaningful rather than random padding: Placemarks, Paths, Polygons. For KML these are alternatives, so choose the one that matches what you need to test.
How a .kml file is identified
A .kml file has no signature at the start. A text format has no identifying leading bytes, so the extension and the reported media type are the only claims about it until a parser actually reads it, which is why validating uploads by extension alone is unsafe.
How the size lands on the exact byte
XML permits whitespace after the root element, so the padding goes there. The document still parses, and the tree is unchanged.
Negative testing with broken KML files
- Invalid. Identifiable, but wrong inside, so it fails during parsing.
- Corrupted. The leading bytes are destroyed. Same length as the valid file.
- Incomplete. Truncated part-way, so it is genuinely shorter.
- Empty. Chosen under Content rather than File Condition: valid structure, no data.
Which failure to reach for, and what to assert for each, is covered in how to make a corrupted file for testing. For upload limits and type checks see testing file upload validation, and for this format's encodings, UTF-16 and BOM test files.
Sample KML content
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document><Placemark><name>Test Point</name>
<Point><coordinates>-74.005974,40.712776,0</coordinates></Point>
</Placemark></Document>
</kml>This shows the shape of the file. Your download is generated fresh at the size you choose, so the values will differ.
How to open and verify the file
Open it in Google Earth or QGIS, or validate the XML with `xmllint --noout file.kml`. Note the coordinate order: KML is longitude,latitude,altitude, which is the reverse of how most people say it.
Media type application/vnd.google-earth.kml+xml · extension .kml · category Data
Generate a .kml file → · questions about sizes, privacy or cost are answered on the site FAQ.
Frequently asked questions about KML files
What identifies a .kml file?
Nothing at the start of the file does. A text format has no identifying leading bytes, so the extension and the reported media type are the only claims about it until a parser actually reads it, which is why validating uploads by extension alone is unsafe.
How can a .kml file be an exact number of bytes?
XML permits whitespace after the root element, so the padding goes there. The document still parses, and the tree is unchanged.
What can go inside the KML file?
There are 3 content options for .kml: Placemarks, Paths, Polygons. For KML these are alternatives, so pick the one matching what you need to test.
Can I download several broken KML files at once?
Yes, select more than one File Condition and you get one ZIP containing a .kml per condition, each named after its condition.
Can the KML file use UTF-16 or a byte-order mark?
Yes. .kml is a text format, so it can be generated as UTF-8, UTF-8 with a byte-order mark, UTF-16 LE or UTF-16 BE. The body is shortened before re-encoding so the finished file still lands on the exact size you asked for. Note that a UTF-16 file always has an even byte count.
How do I open or verify the KML file?
Open it in Google Earth or QGIS, or validate the XML with xmllint --noout file.kml. Note the coordinate order: KML is longitude,latitude,altitude, which is the reverse of how most people say it.