Shapefile vs. GeoJSON vs. GeoPackage: Which Format to Use?

Shapefile vs. GeoJSON vs. GeoPackage: Which Format to Use?

Years ago, a colleague sent me a “complete” dataset of a river basin by email. It arrived as a single file with a .shp extension. I opened it and got an error. He had forgotten the other files that travel with it, and, as I discovered later, the attribute names had been chopped to ten characters, every accented letter in the village names had turned into a question mark, and the file could not hold the new fields we needed. One small choice of file format had cost us two days.

I tell this story because the format question looks trivial and is not. The format you choose decides how much information survives, how easily others can use your data, how fast your software runs, and whether your work will still open in ten years. In this guide I’ll compare the three formats you will meet most often, Shapefile, GeoJSON and GeoPackage, explain exactly where each shines and where it fails, and give you a simple rule for choosing.

Chart: GeoPackage is the best general-purpose format; GeoJSON suits the web; Shapefile is mainly for compatibility.
GeoPackage is the best general-purpose format; GeoJSON suits the web; Shapefile is mainly for compatibility.

The Short Answer

If you want the conclusion before the detail, here it is:

  • GeoPackage is my default for almost everything: one file, modern, open, fast, and free from the old limits.
  • GeoJSON is the best choice for web maps and for exchanging small datasets between programs and developers.
  • Shapefile is the format to use only when someone else demands it, because it is still accepted everywhere.

Now let’s understand why.


What Makes a Good Geospatial Format?

Before comparing, let’s agree on what we are judging. A good vector format should be:

  • Complete: it keeps geometry, attributes, the coordinate system and, ideally, several layers together.
  • Portable: it opens in many programs, on many systems, without special tools.
  • Capable: it handles long field names, accents and non-Latin text, dates, large files and modern data types.
  • Efficient: it is fast to read, write and query, even when data grows.
  • Open: its specification is public, so it won’t disappear if a company changes strategy.
  • Safe to share: it travels as one object and can’t lose parts on the way.

Keep this list in mind. Each format scores differently.


The Shapefile

What it is

Diagram: Choose GeoPackage by default, GeoJSON for web delivery and Shapefile only when another system requires it.
Choose GeoPackage by default, GeoJSON for web delivery and Shapefile only when another system requires it.

The Shapefile was created by Esri in the early 1990s. It is, by a huge margin, the most widely recognized vector format in the world. Almost every GIS, web service and government agency can read it, which explains its survival long after it became technically outdated.

A “file” that is really several files

A Shapefile is not one file but a set of files with the same name and different extensions:

  • .shp: the geometry.
  • .shx: an index of the geometry.
  • .dbf: the attribute table, in the old dBase format.
  • .prj: the coordinate reference system, as text.
  • .cpg: the character encoding of the attribute table.
  • .sbn / .sbx: optional spatial index files.

The first three are mandatory. If you send only the .shp, the recipient gets shapes with no attributes and no location information. This is the number one cause of the “missing files” problem, and the reason people zip the whole set before sharing.

Strengths

  • Universal compatibility. Nearly every tool and organization accepts it.
  • Simple and well understood. Everyone in the field has used it.
  • Stable. The format has barely changed in decades.

Weaknesses (and they are serious)

  • Ten-character field names. Population_density_2020 becomes something like Population. Names collide and meaning is lost.
  • Limited text length. Text fields are capped at 254 characters.
  • Encoding trouble. Accents and non-Latin scripts depend on a separate .cpg file that is often missing or wrong. This is where those question marks come from.
  • A 2 GB size limit for the .shp and .dbf components.
  • One geometry type per file. You can’t mix points and polygons.
  • Weak data types. There is no true date-and-time field, and null values are handled poorly: empty numbers often become zero.
  • No multiple layers. One dataset means one file set, so a project with fifty layers becomes a folder of hundreds of files.
  • No topology and limited metadata.
  • A fragile bundle. Rename or lose one component and the dataset breaks.

When to use it

Use a Shapefile when a client, an agency or a legacy system requires it. Otherwise, store your own work elsewhere and export to Shapefile at the very end, only for delivery.


GeoJSON

What it is

GeoJSON is a text format, based on JSON, for describing geographic features. It was standardized as RFC 7946 in 2016 and has become the natural language of web mapping. If you have ever seen a map on a website built with Leaflet, MapLibre or Mapbox, there is a good chance that GeoJSON was involved.

A GeoJSON file contains features, each with a geometry and a set of properties (the attributes). Geometry types include Point, LineString, Polygon, their “Multi” versions, and GeometryCollection. Features are grouped in a FeatureCollection.

An important rule: coordinates and CRS

The GeoJSON specification states that coordinates are in WGS 84, longitude first and latitude second. Older drafts allowed a CRS definition, but the current standard removed it. This is convenient for the web, but it has two consequences you must know:

  • Longitude comes before latitude. Many people (and some software) get this backwards, and points appear on the wrong side of the world.
  • You can’t store projected coordinates in meters in a standards-compliant way. If your analysis needs a local projected CRS, GeoJSON is not the right storage format.

For more on why this matters, read Coordinate Reference Systems (CRS) Explained Simply.

Strengths

  • Human-readable. You can open it in a text editor and understand it.
  • Perfect for the web. Browsers and JavaScript read it natively.
  • Single file. Geometry, attributes and structure travel together.
  • Flexible attributes. Each feature can carry different properties, and field names have no length limit.
  • Open and simple, which makes it excellent for developers and APIs.

Weaknesses

  • Heavy. Text is verbose. A large dataset can be many times bigger than the same data in a binary format.
  • Slow for big data. There’s no spatial index, so software must read everything.
  • WGS 84 only, which makes precise measurements awkward.
  • No real schema. Nothing guarantees that a field is always a number or always a date.
  • Limited to vector features. No rasters, no multiple layers in one file.
  • Coordinate precision bloat. Writing fifteen decimals for each coordinate wastes space. Six decimals (about 10 centimeters) are usually plenty.

When to use it

Use GeoJSON for web maps, for small to medium datasets, for API exchange and for sharing a quick example with a developer. Don’t use it as the working format for large datasets or analysis.


GeoPackage

What it is

The GeoPackage is an open standard of the Open Geospatial Consortium (OGC), first published in 2014. Technically, it is a SQLite database in a single file with the extension .gpkg, plus a set of rules describing how spatial data is stored inside.

If you want a deeper picture of spatial databases, read Enterprise GIS & Spatial Databases: PostGIS, Geodatabases, and Server Architecture. A GeoPackage is like a small, portable cousin of those systems.

What it can hold

One .gpkg file can contain:

  • Many vector layers, of any geometry type.
  • Raster data and tile pyramids, for example a basemap.
  • Plain attribute tables without geometry.
  • Styles and metadata, depending on the software.
  • Spatial indexes, for fast queries.

Strengths

  • One file. Nothing to lose, nothing to zip, nothing to forget.
  • Any CRS. Projected or geographic, each layer keeps its own definition inside the file.
  • No practical field-name limits, full UTF-8 text support, and proper date and time types.
  • Large capacity, far beyond the old 2 GB limit.
  • Fast, thanks to built-in spatial indexes and database engine.
  • Several layers in one container, ideal for a whole project.
  • Open and standardized, and supported by QGIS, ArcGIS, GDAL and most modern tools.
  • SQL access: you can query it with standard SQL.

Weaknesses

  • Not as universal as Shapefile in some very old systems and agency workflows.
  • Not made for heavy simultaneous editing. SQLite allows many readers but essentially one writer at a time, so it isn’t a substitute for a multi-user database such as PostGIS.
  • Not human-readable. You need software to open it.
  • Not designed for direct use in web browsers. For the web, convert to GeoJSON or vector tiles.
  • Cloud and sync caution. Don’t edit a GeoPackage live from a cloud-sync folder; a sync in the middle of a write can corrupt it.

When to use it

Use GeoPackage as your default working and archive format for desktop GIS projects, for delivering data to people who use modern tools, and for storing many layers together.


Side-by-Side Comparison

FeatureShapefileGeoJSONGeoPackage
Number of files3 to 7 per layer11 for the whole project
Layers per file11Many
Mixed geometry typesNoYes (as a collection)Yes (separate layers)
Field name length10 charactersNo limitNo practical limit
Text encodingFragile (needs .cpg)UTF-8UTF-8
Date and time fieldsDate onlyAs textYes
Size limit2 GBPractical limit, file gets heavyVery large
Coordinate systemAny (in .prj)WGS 84 in the standardAny, stored per layer
Spatial indexOptional extra fileNoneBuilt in
Raster supportNoNoYes
Human-readableNoYesNo
Best forDelivery to legacy systemsWeb maps and APIsWorking data and archives

Other Formats Worth Knowing

The world doesn’t end with these three. A few others appear often:

  • File geodatabase (.gdb): Esri’s folder-based format, rich in features such as domains and topology. Readable in QGIS, but best inside the Esri world.
  • KML / KMZ: Google Earth’s format. Good for presentation and sharing placemarks, poor for analysis.
  • GML: an XML-based OGC format. Verbose, but required by many government services.
  • CSV with coordinates: the humblest format of all, a table with X and Y columns. Surprisingly useful for points, but it carries no CRS.
  • FlatGeobuf and GeoParquet: modern, efficient formats designed for large datasets and cloud workflows. Worth watching and increasingly used.
  • GeoTIFF: for raster data. See Vector vs. Raster Data: The Complete Guide.

How to Choose: A Simple Decision Guide

Ask yourself these questions in order:

  1. Is the data going on a web map or through a web API? Choose GeoJSON (or vector tiles for large data).
  2. Is someone requiring a specific format? Provide what they ask for, usually Shapefile, but keep your master copy elsewhere.
  3. Are you storing, analyzing or archiving your own data? Choose GeoPackage.
  4. Do many people need to edit the same data simultaneously? Don’t use a file at all: use a spatial database such as PostGIS.
  5. Is the dataset huge and cloud-based? Consider GeoParquet, FlatGeobuf or Cloud Optimized GeoTIFF for rasters.

The rule I teach my students: work in GeoPackage, publish in GeoJSON, deliver in Shapefile only if asked.


How to Convert Between Formats

Conversion is easy, and a good habit. In QGIS, right-click a layer and choose Export > Save Features As, then pick the format, the CRS and the encoding. For batch work, the command-line tool ogr2ogr, part of GDAL, is wonderful.

# Shapefile to GeoPackage
ogr2ogr -f GPKG project.gpkg roads.shp

# GeoPackage layer to GeoJSON in WGS 84
ogr2ogr -f GeoJSON roads.geojson project.gpkg roads -t_srs EPSG:4326

A few precautions when converting:

  • Check the CRS before and after. For GeoJSON, reproject to WGS 84.
  • Check the encoding when reading old Shapefiles. Set it explicitly if accents look wrong.
  • Check field names and types. A field truncated in the Shapefile stays truncated forever, so convert as early as possible, from the original source if you still have it.
  • Reduce coordinate precision for web GeoJSON to keep files light.
  • Validate the geometry after conversion, since some conversions create invalid shapes.

Common Mistakes

  • Sending only the .shp file. Always send the whole set, zipped.
  • Using Shapefile as the master format and then wondering why fields were truncated.
  • Putting projected coordinates in a GeoJSON and breaking web maps.
  • Mixing up longitude and latitude order.
  • Editing a GeoPackage in a cloud-synced folder.
  • Treating GeoJSON as a database and loading a 500 MB file in the browser.
  • Forgetting the encoding and delivering garbled names.
  • Never documenting which CRS and format version you delivered.

Final Thoughts

Formats are like containers. A good container protects its contents, travels well and doesn’t surprise the person who opens it. The Shapefile earned its place in history, and it will be with us for years, but I no longer reach for it by choice. GeoJSON is the lingua franca of the web, and GeoPackage is the quiet workhorse that has replaced the old Shapefile folders in my daily work.

Spend ten minutes today converting one of your projects to GeoPackage. Open it, look at the layers, and notice how much cleaner it feels. That small habit will save you the kind of two-day mistake I made years ago.

Where to go next: read Understanding Spatial Data Types and Attributes to learn what you are actually storing, and Metadata in GIS: Why It Matters and How to Create It to document it properly.

Rachid Khouri

Rachid Khouri

Rachid Khouri is a CAD, BIM and GIS professional, Autodesk Authorized Developer, trainer and technical author with more than 30 years of experience, working with AutoCAD since 1992. He founded GISauthority.com to share practical guidance on GIS and spatial technologies.