Four dataset sizes, one real point collection and two real CAD fixtures. Measured KML/KMZ sizes at deflate 6 and 9, ZIP structure, parseability, and a DWG vs DXF comparison of entropy, printable bytes and compressibility.
Some search queries are answered badly by every result on the first page. In the Search Console data for the site I work on, kml vs kmz, kmz vs kml and dwg vs dxf each produce a couple of dozen impressions and zero clicks. Those are people asking a definition question and finding nothing but converter buttons. This article is the page they were looking for — with measurements instead of adjectives.
There is a trap in the question itself. KML and KMZ are the same XML in different packaging. DWG and DXF are not the same drawing in different encodings. Treating the two comparisons as analogous leads to exactly the wrong advice. I will measure each pair separately, using real files shipped with geoo.app.

Figure 1. The first pair differs by packaging; the second differs by data model. Only the first can be compared byte-for-byte.
KML is an XML dialect for geographic annotation, standardised by the OGC. A KMZ is a ZIP archive containing that KML — conventionally named doc.kml — plus any images, icons and models it references. Nothing about the XML changes when you rename the file.
I checked this on the project's 665-byte fixture, testdata/kmz/simple.kmz. It contains two entries:
| Entry | Raw | Compressed |
|---|---|---|
image.png | 883 B | 140 B |
simple.kml | 429 B | 241 B |
Decompressing simple.kml from the archive produces bytes identical to the standalone testdata/kml/simple.kml. That is the whole distinction: a KMZ is a KML with its dependencies bundled and its text compressed.
The practical consequences are immediate:
<Placemark>. A KMZ cannot.The companion article on KML & KMZ to CSV or Excel covers what happens after that decompression. Here I want to measure the container itself.
I generated KML from one real dataset of 17,289 named WGS84 points, sliced to four sizes, then packaged each KML into a single-entry KMZ. Three ZIP settings were measured: deflate level 6, deflate level 9, and stored (no compression). All byte counts are exact.
| Points | KML | CSV | KMZ deflate-6 | KMZ deflate-9 | KMZ stored | deflate-6 / KML |
|---|---|---|---|---|---|---|
| 100 | 11,495 | 3,477 | 2,136 | 2,114 | 11,607 | 18.6% |
| 1,000 | 114,145 | 35,027 | 16,326 | 15,977 | 114,257 | 14.3% |
| 5,000 | 576,582 | 181,464 | 78,637 | 76,646 | 576,694 | 13.6% |
| 17,289 | 1,994,339 | 628,390 | 272,948 | 266,148 | 1,994,451 | 13.7% |

Figure 2. Every variant grows linearly; only deflate changes the scale.
import io, zipfile
def make_kmz(kml: bytes, level: int = 6, stored: bool = False) -> bytes:
buf = io.BytesIO()
with zipfile.ZipFile(
buf, 'w',
zipfile.ZIP_STORED if stored else zipfile.ZIP_DEFLATED,
compresslevel=None if stored else level,
) as z:
z.writestr('doc.kml', kml)
return buf.getvalue()
Three findings fall straight out of the table.
The compression ratio is almost constant. From 100 points to 17,289, the deflate-6 ratio moves from 18.6% to 13.7% and then flattens. That is because the redundancy is structural, not data-dependent: <Placemark><name>, <Point><coordinates> and the closing tags repeat once per feature regardless of what the coordinates are. After the first few thousand features, deflate has a full dictionary and adding more of the same pattern does not change the ratio. You can estimate a large KMZ from a 1,000-point sample to within a couple of percentage points.

Figure 3. The stored ZIP tracks the KML at 100%; deflate-6 and deflate-9 sit near 14% across the whole range.
Level 9 is barely worth it. At 17,289 points, deflate-9 produces 266,148 bytes against 272,948 for level 6 — a 2.5% saving. For a browser-based tool, that extra 6.8 KB is rarely worth the extra CPU time. Level 6 is a sensible default.
A stored ZIP is larger than the KML. 1,994,451 versus 1,994,339 bytes: 112 bytes of ZIP overhead (local header, filename, central directory, end record). On the 100-point file the overhead is the same 112 bytes, which is a much bigger relative penalty. So "put it in a ZIP" is not a size optimisation by itself — compression is. This is also why the 665-byte sample KMZ has 381 bytes of compressed payload but occupies 665 bytes on disk: the rest is ZIP structure.
And for context, the plain CSV of the same 17,289 points is 628,390 bytes. The KMZ is smaller than the CSV — 273 KB against 628 KB — because the CSV has less repeated structure for deflate to eliminate. "XML is verbose" is a statement about the uncompressed form, not about what crosses the network.
I ran four mechanical tests against the same payload. These are not opinions about software compatibility; they are things you can check on bytes without opening any GIS application:
| Test | KML | KMZ |
|---|---|---|
| Bytes | 1,994,339 | 272,948 |
Starts with PK | no | yes (50 4b 03 04) |
Grep finds <Placemark> | yes | no |
zipfile can open it | no | yes |
| Entries found | — | doc.kml |

Figure 4. A KMZ is a valid ZIP. A KML is a valid XML document. Neither is both.
The measured ZIP entry for the 17,289-point KMZ is doc.kml, 1,994,339 bytes uncompressed → 272,836 compressed, method 8 (DEFLATE), CRC 1199888234, header offset 0, no extra field, no comment, flag bits 0. The 112-byte difference between the compressed entry (272,836) and the whole file (272,948) is the ZIP bookkeeping.
import zipfile, io
from xml.etree import ElementTree as ET
def read_any_kml(blob: bytes) -> bytes:
if blob[:2] == b'PK':
with zipfile.ZipFile(io.BytesIO(blob)) as z:
kmls = [n for n in z.namelist() if n.lower().endswith('.kml')]
if not kmls:
raise ValueError('KMZ has no .kml entry')
main = 'doc.kml' if 'doc.kml' in kmls else \
min(kmls, key=lambda n: n.count('/'))
if main.startswith('/') or '..' in main.split('/'):
raise ValueError('unsafe ZIP entry name')
blob = z.read(main)
ET.fromstring(blob) # fail early on malformed XML
return blob
A detail that belongs in any real reader: KML files may carry a different default namespace, or no namespace at all, especially older Google Earth exports. A parser that hardcodes {http://www.opengis.net/kml/2.2} will silently return zero placemarks on those files. Match on the local tag name, or normalise the namespace, and verify that the feature count is non-zero before declaring success.
Another practical one: KMZ entries can be nested (images/icon.png), and KML references them with relative paths. If you extract a KMZ to a temporary directory, keep the directory structure; if you read it in memory, rewrite those references or the icons will disappear. This is the main reason a KMZ is preferable for hand-off — it is the only one of the two that can actually be self-contained.
In a client-side converter, the size distinction is not just a download statistic. The user selects a File, it is read into an ArrayBuffer, the first two bytes decide whether decompression is needed, and only then does DOMParser see the XML. For the 17,289-point case, 273 KB arrive over the network and 1,994,339 bytes of XML exist in memory afterwards — before the DOM tree, before the output string, before the Blob that will be handed to the browser as a download.
async function loadKmlFromAnything(file: File): Promise<string> {
const buf = new Uint8Array(await file.arrayBuffer());
const isZip = buf[0] === 0x50 && buf[1] === 0x4b; // 'PK'
const xmlBytes = isZip ? await unzipFirstKml(buf) : buf;
const xml = new TextDecoder('utf-8').decode(xmlBytes);
const doc = new DOMParser().parseFromString(xml, 'application/xml');
if (doc.querySelector('parsererror')) throw new Error('malformed KML');
return xml;
}
That gap is the same pattern the eight-format benchmark found for gzip: compression reduces transfer size, not working-set size. A KMZ is the right thing to send and the wrong thing to assume is small once opened. For large archives, move both the inflate step and the XML parse into a Worker, and avoid holding the decompressed string and the parsed DOM at the same time for longer than necessary. A 2 MB KML is harmless; a 200 MB one will stall the main thread or exhaust a mobile tab.
Now the second pair, where the usual advice goes wrong. Autodesk's DWG is a compact binary drawing database. DXF (Drawing Exchange Format) is an ASCII text representation designed for interchange between CAD systems. They are different artefacts with different purposes — and, importantly, the two fixtures measured here are not the same drawing. One is a 190,039-byte boundary drawing in testdata/dwg/, the other is a 23,027-byte QGIS-exported DXF in testdata/dxf/.
That last sentence matters. I am not going to claim "DXF is 8× smaller than DWG". That would compare two unrelated files. What can be compared honestly are structural properties, which are exactly what determines how a converter must treat them.
| Metric | DWG fixture | DXF fixture |
|---|---|---|
| Size | 190,039 B | 23,027 B |
| Version marker | AC1018 (header bytes 0–5) | AC1015 ($ACADVER in HEADER) |
| First bytes | 41 43 31 30 31 38 00 … | 999\nDXF created from QGIS\n |
| Printable ASCII | 34.7% | 99.4% |
| Shannon entropy | 7.6251 bits/byte | 4.517 bits/byte |
grep SECTION | no | yes |
| Zip deflate-6 | 166,619 B (87.7% of original) | 3,475 B (15.1% of original) |

Figure 5. Two fixtures of different origin. Structural metrics, not a same-drawing size comparison.
The DXF begins with group code 999 (a comment), then 0 / SECTION / 2 / HEADER. DXF is a sequence of group-code / value pairs, two lines at a time: the code says what the value means, the value is plain text. Counting them in this fixture gives 1,827 pairs, including 15 LWPOLYLINE entities and the usual SECTION, TABLE, BLOCK_RECORD and LAYOUT records. You can read the geometry with a text editor.
from collections import Counter
import math
def dxf_pairs(text: str):
lines = text.splitlines()
return [(lines[i].strip(), lines[i+1].strip())
for i in range(0, len(lines) - 1, 2)]
def entropy(b: bytes) -> float:
c = Counter(b)
return -sum((n / len(b)) * math.log2(n / len(b)) for n in c.values())
pairs = dxf_pairs(open('testdata/dxf/test.dxf', 'rb').read().decode('latin-1'))
entities = Counter(v for code, v in pairs if code == '0')
print(len(pairs), entities['LWPOLYLINE'])
# 1827 15
The entropy numbers explain the compression gap. The DWG sits at 7.6251 bits/byte, close to the 8-bit maximum — it is already dense, so deflate can only squeeze it to 87.7% of its size. The DXF sits at 4.517 bits/byte with 99.4% printable bytes, because most of it is repeated numeric formatting, whitespace and group-code labels; deflate reduces it to 15.1%. A text interchange format carries an enormous amount of redundancy, and that redundancy is exactly what a ZIP removes.
import io, zipfile
def zipped_size(blob: bytes, level: int = 6) -> int:
out = io.BytesIO()
with zipfile.ZipFile(out, 'w', zipfile.ZIP_DEFLATED,
compresslevel=level) as z:
z.writestr('payload', blob)
return len(out.getvalue())
This is the actual reason the two formats exist side by side. DWG is the working format: compact, versioned, and fast for a CAD kernel to read — but proprietary enough that implementing a reader is a serious project (the browser tool here uses a LibreDWG-based WebAssembly parser). DXF is the interchange format: verbose, human-readable, and widely supported by libraries that never need to understand the binary database. Choosing between them is not a compression decision; it is a compatibility decision.

Figure 6. Decisions derived from the measured structure, size and parseability.
Two rules the measurements genuinely support:
AC1015 while the DWG declares AC1018, and neither file is the source of the other."KMZ is a newer version of KML." No. KMZ is a ZIP wrapper, and a KMZ can contain KML 2.2 from any era. There is no version relationship.
"Renaming .kml to .kmz converts it." It creates a file with the wrong extension that no ZIP reader can open. The reverse — renaming .kmz to .kml — gives an XML parser a binary file with a PK header.
"A bigger ZIP always means a bigger file." A stored ZIP is larger than its payload. Compression level, not the container, determines the saving — measured above at 112 bytes of overhead.
"DXF is just DWG as text." It is a separate interchange representation. Extended entity data, object dictionaries and some version-specific features do not map one-to-one. The two fixtures here are different drawings with different version markers.
"Just compare the file sizes to pick one." For KML/KMZ it is valid (same content). For DWG/DXF it is not (different content). This is the single most common misconception the search queries behind this article are really asking about.
"The 13.7% ratio applies to every KML." It applies to this point dataset with one attribute and highly repetitive markup. Rich styling, embedded descriptions or long unique attribute values will compress differently. Measure your own file; the ratio is stable across sizes, not across content types.
zipfile, deflate levels 6 and 9. Other ZIP implementations and levels will shift absolute byte counts slightly; the structural conclusions will not change.zipfile, ElementTree and plain byte searches, not behaviour in Google Earth, QGIS, ArcGIS or AutoCAD. Those products have their own quirks (especially around KML namespaces and KMZ entry naming).The fixtures are real files in the project's test data; comparable public samples are on the sample data page.
python3 - <<'PY'
import io, zipfile, os
kml = open('generated.kml','rb').read()
for level, stored in ((6, False), (9, False), (None, True)):
b = io.BytesIO()
with zipfile.ZipFile(b, 'w',
zipfile.ZIP_STORED if stored else zipfile.ZIP_DEFLATED,
compresslevel=level) as z:
z.writestr('doc.kml', kml)
print(level or 'stored', len(kml), '->', len(b.getvalue()))
# For the shipped 665-byte sample:
z = zipfile.ZipFile('testdata/kmz/simple.kmz')
print([(i.filename, i.file_size, i.compress_size) for i in z.infolist()])
PY
The last line should print [('image.png', 883, 140), ('simple.kml', 429, 241)].
A short FAQ:
Is a KMZ smaller than a KML? For any non-trivial file, yes: measured at 13.7–18.6% of the KML across four dataset sizes. For a tiny file, ZIP overhead can make the KMZ larger.
Can I open a KMZ in a text editor? No — it starts with PK. Unzip it first; the doc.kml inside is ordinary XML.
Should I convert DWG to DXF to see what is inside? You do not need to convert this particular DXF; it is already text. For a real DWG you need a parser, which is why browser tools ship a WebAssembly build of a DWG library.
Which one should I email? KMZ if there are icons or the file is large; KML if the recipient needs to read or diff it; DXF if the recipient is a GIS tool without AutoCAD support.
The short version: KML vs KMZ is a packaging question you can answer with a ruler. DWG vs DXF is a data-model question you should answer by asking who will read the file.