Why Format Choice Matters
Geospatial data comes in many formats, and the one you choose affects interoperability, file size, tooling support, and how easily you can work with the data in code. Three formats dominate day-to-day GIS and web mapping work: GeoJSON, Shapefile, and KML. Each has a distinct origin, use case, and set of trade-offs.
Quick Comparison Table
| Attribute | GeoJSON | Shapefile | KML |
|---|---|---|---|
| File type | Single .json / .geojson | Multiple files (.shp, .dbf, .shx, …) | Single .kml or .kmz (zipped) |
| Format | JSON (text) | Binary | XML (text) |
| Coordinate system | WGS 84 only (RFC 7946) | Any CRS (via .prj) | WGS 84 only |
| Max attribute name length | Unlimited | 10 characters | Unlimited |
| Geometry types | 7 (incl. GeomCollection) | Many, inc. Multipatch | Point, LineString, Polygon + overlays |
| Styling support | None (external) | None (external) | Built-in |
| Best for | Web APIs, JavaScript | Desktop GIS, large datasets | Google Earth, visualization |
| Human-readable | Yes | No | Yes |
GeoJSON
GeoJSON is the dominant format for web mapping. It's plain JSON, which means any developer can read, write, and parse it with standard tools. It's natively supported by Leaflet, Mapbox GL JS, MapLibre, D3.js, and virtually every modern mapping API.
Strengths
- Human-readable and easy to debug in any text editor or browser console.
- Native JSON parsing — no special libraries required in JavaScript.
- Directly supported by GitHub (renders as an interactive map), geojson.io, and most mapping APIs.
- Single file — easy to share, version-control, and serve over HTTP.
Weaknesses
- Text-based format — larger file sizes than binary formats for the same data. (Use TopoJSON or FlatGeobuf for large datasets.)
- Locked to WGS 84 (EPSG:4326). You must reproject data before using GeoJSON.
- No built-in attribute indexing — not ideal for server-side queries on millions of features.
Shapefile
The Shapefile format was developed by Esri in the early 1990s and remains the most widely used format in desktop GIS software (ArcGIS, QGIS). It's not a single file but a collection — at minimum .shp (geometry), .dbf (attributes), and .shx (index).
Strengths
- Universally supported by GIS desktop software and many spatial databases.
- Binary format — compact and fast for large datasets.
- Supports any coordinate reference system via the
.prjfile. - Widely used in government and academic data distribution.
Weaknesses
- Attribute field names are limited to 10 characters — a notorious pain point.
- No support for NULL values in the traditional sense; mixed geometry types are not allowed per file.
- Multi-file format makes it awkward to email or version-control.
- Not natively parseable by web browsers without conversion.
KML (Keyhole Markup Language)
KML was developed by Keyhole, Inc. (later acquired by Google) and is the native format of Google Earth and Google Maps. It's XML-based and designed with visualization in mind, including built-in support for styling, camera positions, and time animations.
Strengths
- Built-in styling: colors, icons, line widths, fill opacity — all defined in the file.
- Supports rich descriptions with HTML, images, and links embedded in feature popups.
- Natively opens in Google Earth and Google Maps.
- KMZ (zipped KML) bundles the file with embedded icons and images.
Weaknesses
- Verbose XML leads to large file sizes for complex datasets.
- Poor interoperability with modern web mapping stacks — requires conversion to GeoJSON for Leaflet/Mapbox.
- Largely replaced by GeoJSON in modern development workflows.
When to Use Each Format
- GeoJSON: Web applications, REST APIs, JavaScript mapping, version-controlled data, quick prototyping.
- Shapefile: Desktop GIS workflows, large datasets, data from government portals, projects requiring a specific CRS.
- KML: Sharing with non-technical users via Google Earth, adding styled overlays to Google Maps, time-animated geographic storytelling.
Converting Between Formats
The good news: all three formats are interconvertible. GDAL/OGR (via the ogr2ogr command) is the gold-standard command-line tool for format conversion. Online tools like geojson.io, MyGeoData, and Mapshaper offer browser-based conversion with no installation required.