# KML to KMZ converter

> Pack a KML file into a KMZ: the same placemarks in a smaller file that Google Earth and Google My Maps open directly. Free, and no account needed.

Open the tool: https://spatibase.com/tools/kml-to-kmz/

The Spatibase KML to KMZ converter zips a KML file into a KMZ in your web browser. What you get:

- **The same KML, smaller.** It goes into the archive unchanged, named doc.kml, so placemarks, folders, styles and descriptions are exactly as before, and the KMZ is usually a fraction of the size.
- **Local images left out.** Images the KML links by a path on your computer are not added, and the converter tells you when there are any.
- **Nothing is uploaded.** KML files up to 50 MB, no account.

## What it does
- Convert KML to KMZ (zipped KML)
- Keeps the KML unchanged, as doc.kml
- Smaller files for email and uploads
- Warns about images linked from your computer
- Map preview of the file before you download
- Also converts the KML to GeoJSON and CSV
- Runs in the browser: nothing is uploaded

## How to convert KML to KMZ
1. Drop the .kml file on the box above, or press Choose a file. Try the sample to see the Barcelona KML zipped.
2. Check the map, and read the note under it if the KML links to icons or photos on your computer.
3. Press Download KMZ. The file has the same name with .kmz at the end.
4. Open it in Google Earth (File → Open in Google Earth Pro, or import into a project on the web), or add it as a layer in Google My Maps.

## Formats and limits
- **Opens:** .kml or .kmz, up to 50 MB. Other map files (KML, KMZ, GPX, GeoJSON, shapefile, CSV) convert too.
- **Downloads:** KMZ, GeoJSON, CSV of the same features.
- **Privacy:** the file is read in your browser and never uploaded.
- Try it with a sample: https://spatibase.com/tools/kml-to-kmz/?sample=1
- Download the sample file (the one Open a sample opens): https://spatibase.com/tools/samples/barcelona.kml

## What goes into the KMZ
| What | What happens |
|---|---|
| Your KML | Unchanged, as `doc.kml` at the top of the zip: every placemark, folder, style and description. |
| File size | Smaller. KML is repetitive text and compresses well. |
| Icons and images by web address (`http…`) | Still work: Google Earth loads them from the internet as before. |
| Icons and images by a path on your computer | Not added. The converter says when the KML links any, so you can pack them yourself. |
| Network links | Kept as links. The data they point to stays online. |

## Why make a KMZ, and what goes in it
A KMZ helps in two ways:

- **Smaller to send.** Each placemark repeats the same tags, so KML zips well: the Barcelona sample goes from 18 KB to about 5 KB. Attachments and uploads get faster, and a KMZ is less likely to hit an email size limit.
- **One file, pictures included.** A KMZ can carry the photos and icons the KML uses, so the map looks the same on another computer. Google names the main file `doc.kml` and keeps the rest in a `files/` folder.

And two limits to keep in mind:

- **What this converter packs.** Only the KML. If it links images by a relative path such as `files/icon.png`, zip the KML and the images yourself (see the code below), then rename the .zip to .kmz.
- **Size limits don’t change.** Google My Maps checks a KML or KMZ after unzipping it, and the limit is 5 MB, so zipping won’t get a big layer past it. Split the layer or remove detail instead.

## Make a KMZ in JavaScript
The converter zips with `fflate`, a small zip library. The same in your own code, in a browser or Node.js:

```js
import { zipSync, strToU8 } from 'fflate'

// kmlText: the KML as a string
const kmz = zipSync({ 'doc.kml': strToU8(kmlText) })

// in a browser: a file to download
const blob = new Blob([kmz], { type: 'application/vnd.google-earth.kmz' })
```

With images, on the command line: name the KML `doc.kml`, keep the images in `files/` next to it, then run `zip -r places.kmz doc.kml files/`.

## Frequently asked questions
### Is a KMZ just a zipped KML?
Yes. A KMZ is a zip archive with a KML inside, usually named doc.kml, and sometimes the images and icons it uses. Google Earth and Google My Maps open both kinds of file.

### Does converting KML to KMZ change my data?
No. The KML goes into the zip unchanged, so names, descriptions, styles and folders stay exactly as they were. Unzipping the KMZ gives you the same file back.

### Why don’t my custom icons show after converting?
The KML points to icons or photos on your computer (a relative path such as files/icon.png), and those files aren’t in the KMZ. Put the KML, renamed doc.kml, in a folder with the images, keeping the same paths, and zip that folder’s contents.

### Can I make a KMZ in Google Earth instead?
Yes. In Google Earth Pro, right-click a folder or place under Places, choose Save Place As and pick the Kmz type. Google Earth then also packs the local images the KML uses.

### Will a KMZ get past the 5 MB limit of Google My Maps?
No. My Maps measures KML and KMZ files after unzipping them, and the limit is 5 MB either way. Split the data into several layers, or simplify long lines, to fit.

## Next step
Turn the file into a live map your team can edit: **Save to Spatibase (free)** on the page saves it to a free Spatibase project (https://app.spatibase.com/signup), your places on a map you can edit and a live GeoJSON address for your site. Or download the GeoJSON and import it by hand (https://spatibase.com/docs/content/import/).
