GeoConvert
Resources

Extract KML from KMZ: doc.kml, multiple files and resources

Updated · 8 min read

A KMZ is a ZIP archive. To recover every file, extract the entire archive with a ZIP utility; to get only the main KML, use KMZ to KML. GeoConvert returns the validated selected KML document without rewriting its bytes, but it does not download the other archived resources or merge multiple KML documents.

Try the converter →

Choose main-document extraction or full archive extraction

Main-document extraction is useful for inspecting XML, editing placemarks or passing a standalone KML to another tool. Full archive extraction is needed when the project includes icons, images, overlays, models or additional KML files that you also need to retain.

Renaming a KMZ to .kml does not decompress it and produces a mislabeled ZIP file. If a file manager does not recognize .kmz, make a copy, rename the copy to .zip and extract it. Keep the original archive as a reference.

Extract the selected KML with GeoConvert

The browser tool selects doc.kml at the archive root, ignoring case. If that file does not exist, there must be exactly one .kml anywhere in the archive. A nested folder/doc.kml is not the special root doc.kml; when it is the only KML it can still be selected by the single-document rule.

Every KML member is checked, even when it is not selected. Malformed or unsafe XML elsewhere in the archive can therefore cause rejection. NetworkLink fetching and automatic merging are not part of this workflow. An unsupported resource reference can also be rejected by the XML safety policy; use a desktop workflow for a resource-rich project.

  1. Open the KMZ to KML tool linked on this page and add the KMZ.
  2. Run the extraction and download the .kml. Coordinates stay WGS 84; extraction does not reproject or flatten the document.
  3. Open the output in a text editor and inspect its Document, Folder and Placemark structure. Compare it with the selected source member if exact preservation is important.
  4. If icons or images are missing when opening the KML, recover the full archive and check the resource paths rather than converting the document again.

Resolve multiple KML files explicitly

Google recommends one main KML document for a portable KMZ. Do not rely on different applications selecting the same first member from an archive with multiple KML files. GeoConvert uses its documented selection rule rather than an arbitrary ZIP entry order.

The root-doc-with-extra.kmz sample contains root doc.kml and extra.kml: the main document is selected and extra.kml is not merged. The ambiguous-two-kml.kmz sample has two KML documents without root doc.kml and is intended to be rejected. These fixtures let you check selection behavior without relying on a private project.

  1. List archive entries with a ZIP utility before deciding which document is the main one.
  2. Inspect candidate KML files in a text editor. Check their placemarks, folders and NetworkLink elements; ask the sender when the intended entry point is unclear.
  3. Extract all documents when you need them all. Open or convert each relevant KML separately, or merge them deliberately in a GIS tool after checking CRS and duplicate features.
  4. When rebuilding a KMZ, place one intended main KML at the root and retain resource directories. Do not just rename one arbitrary member to doc.kml and assume its links remain correct.
unzip -l project.kmz
unzip project.kmz -d project-extracted

Preserve resource paths after extraction

A reference such as files/icon.png is resolved relative to the KML document location. If doc.kml remains beside the files directory after extraction, the relative path retains its meaning. Moving only doc.kml to another folder breaks that link even though its XML is unchanged.

The standalone KML download contains the main document, not its image bytes. Google Earth presentation and GIS feature conversion are different tasks: a vector export cannot reproduce all overlays, styles and models. A remote URL also remains a remote dependency; unzipping does not make it an offline resource.

After full extraction, inspect href and image src references and confirm every expected local file exists. Open the extracted project in the destination application and check the icons and overlays you actually need. If you move files, update their paths deliberately or rebuild the same relative directory layout.

Troubleshoot a failed or incomplete extraction

No KML found: inspect the archive contents and confirm it is a genuine KMZ rather than a ZIP containing another ZIP. Multiple KML without root doc.kml: use explicit full extraction and select the intended document. Invalid XML: repair the source or ask for a new export, including any unselected KML members.

A smaller placemark count does not necessarily mean extraction lost bytes: the chosen main KML may not contain features stored in another member or referenced remotely. Compare document names and archive structure first. A main-document-only download is intentionally not a complete archive export.

The automated Node WASM fixture check returned the 917-byte sample doc.kml with byte-for-byte equality. The separate root-doc-with-extra fixture selected doc.kml and warned about one ignored member; the ambiguous fixture failed with BAD_KMZ. These checks cover these controlled inputs, not a manual Google Earth acceptance test. For an exact audit, compute a checksum of the selected source KML and the downloaded output. An equal checksum verifies those document bytes; it does not verify that all external resources are present or that a downstream viewer renders them identically.

Sample files

Frequently asked questions

Must the KML inside a KMZ be called doc.kml?
No. A single KML document can have another filename. GeoConvert prefers a root doc.kml, otherwise requires exactly one KML member.
Can I extract all KML files with the online tool?
The KMZ to KML tool emits only the selected main document. Use a ZIP utility to recover every archive member, then handle each KML explicitly.
Does KMZ to KML preserve styles?
The selected validated KML document is returned unchanged, so its inline styles stay in its text. Separate icons, images and other archived resources are not included in the standalone download and their paths may stop resolving.

Related guides and conversions

Sources