Home / GIS and Open Map Data for Beginners

GeoJSON to Shapefile: QGIS, ogr2ogr, and GeoPandas Routes, and the Four Things That Break on the Way

Code on a screen seen through a tilt-shift lens effect

Photo: Markus Spiske / Pexels

GeoJSON is how the web speaks geography; the shapefile is how a generation of GIS software and government agencies still demand it. Converting between them is a daily chore, and every tool does it in seconds. What no tool does for you is warn you about the shapefile format's limits, which are older than the web and enforced silently: your data comes out the other side slightly amputated, and nothing complains. This guide gives the three standard routes, QGIS for the visual check, ogr2ogr for the command line, and GeoPandas for pipelines, then spends its real length on the four failure modes and how to catch each one. For the GeoJSON side of the pair, our GeoJSON guide covers the format itself; for the format's modern rival, see shapefile vs geodatabase.

Interactive tool

Convert Without Losing Data: The Checklist

Check off each step as you finish it. Your progress stays on this page.

0 of 7 complete

0% done

Before You Convert: Three Facts About Your Input

First, GeoJSON is always WGS 84. RFC 7946 fixed the coordinate reference system: a conforming GeoJSON file's coordinates are longitude and latitude in WGS 84, full stop. If your file's numbers are actually projected meters written by a nonconforming tool, they are already wrong, and conversion will faithfully preserve the wrongness into the shapefile. Second, GeoJSON tolerates what shapefiles forbid: mixed geometry types in one file, properties nested inside objects and arrays, long descriptive field names, and nulls wherever they please. The conversion is therefore a negotiation, and section four is the negotiation failing, item by item. Third, decide your target CRS now. The shapefile can be written in any CRS, and if the recipient expects projected meters (a state plane or UTM deliverable, usually), the conversion is the moment to reproject, not an afterthought afterward.

Route 1: QGIS (Best When You Want to See the Damage)

  1. Load the GeoJSON: drag the file onto the QGIS window, or use Layer, Add Layer, Add Vector Layer.
  2. Right-click the layer and choose Export, Save Features As.
  3. Set Format to ESRI Shapefile, choose the file name and location.
  4. Set the CRS field: leave it as the layer's WGS 84 for a like-for-like conversion, or choose the target system to reproject during export.
  5. Expand the layer options if you need to rename fields before the ten-character cut does it for you (see below).
  6. Click OK, then load the resulting shapefile back in and compare counts and a few attribute values against the source. That last step, reloading your own output, is the professional habit this whole article is really about.

Route 2: ogr2ogr (Best for Scripts and Repeatability)

The GDAL command line tool converts in one line:

```

ogr2ogr -f "ESRI Shapefile" out.shp in.geojson

```

Add -t_srs EPSG:5070 (or your target's code) to reproject during the conversion. Add -nlt POLYGON style flags when you must force a single geometry type (see mixed geometry below). ogr2ogr prints warnings about field name truncation and dropped fields to the console; in scripts, read those warnings, because they are the only place the amputations are announced. GDAL also writes the .prj file from the target CRS automatically, which matters in section four.

Route 3: GeoPandas (Best Inside a Python Pipeline)

```python

import geopandas as gpd

gdf = gpd.read_file("in.geojson")

gdf = gdf.to_crs(5070) # optional reproject

gdf.to_file("out.shp")

```

The driver is inferred from the extension. GeoPandas will warn about truncated field names in the same spirit as ogr2ogr (it uses GDAL underneath). The pipeline advantage is what you can do before the write: rename fields deliberately, flatten nested columns, split by geometry type, and assert row counts, all in code that runs the same way every time. If this conversion will ever be repeated, this is the route to build.

Lines of code on a laptop screen
Lines of code on a laptop screen

The Four Things That Break

1. Field names are truncated to ten characters. The shapefile's attribute table is a dBase file with a ten-character column limit. population_2020 and population_2019 both become population, and the second overwrites or collides with the first. Fix it before conversion: rename fields to deliberate short names (pop_2020, pop_2019) in QGIS's export options, in ogr2ogr with SQL, or in GeoPandas with a rename, and keep a mapping note for the recipient.

2. One geometry type per file, no exceptions. A shapefile holds points, or lines, or polygons, never a mixture, and even Point and MultiPoint are different types. A GeoJSON file with mixed types must be split into one shapefile per type. GeoPandas makes this a groupby; ogr2ogr takes -nlt plus a filter per pass; QGIS's export will push you to choose. Collections and null geometries need the same pre-pass.

3. Nested and exotic values are flattened or dropped. GeoJSON properties containing objects or arrays have no dBase equivalent and will be dropped or stringified unpredictably. Datetimes lose their time (dBase dates are date-only), long text is cut at the field width (254 characters), and nulls in numeric fields can emerge as zeros. Flatten nested properties into named columns beforehand, and spot-check the longest text and any null-heavy columns after conversion.

4. The output is a set of files, and the set is the deliverable. A shapefile is at minimum three files: .shp (geometry), .shx (index), and .dbf (attributes), plus .prj (the CRS definition) and usually .cpg (text encoding). Send one without the others and the recipient gets a corrupt or CRS-less dataset. Zip the set and send the zip, every time. A missing .prj deserves special dread: the numbers arrive with no statement of what they mean, and the recipient's software guesses, which is how data ends up in the ocean off West Africa, at coordinate zero-zero.

Two More Limits Worth Knowing Before They Know You

Encoding. The .dbf table predates universal UTF-8, and text in languages beyond plain ASCII survives conversion only if the encoding is declared. The .cpg file in the output set is that declaration; if your place names come back as mojibake in the recipient's software, the .cpg was missing or wrong, and regenerating the set with the encoding set explicitly (QGIS and GDAL both expose it) is the fix. Check one accented name in the output before shipping, the same way you check one known coordinate.

Size. Shapefile component files have a practical ceiling of 2 GB each, a limit inherited from the format's 32-bit heritage and documented by Esri. A national-scale GeoJSON dataset can sail past it in conversion even when the JSON itself seemed manageable, because dBase storage is less compact than text for attribute-rich data. If your conversion approaches the ceiling, split the output by region or category, or move the deliverable to GeoPackage, whose limits are effectively out of reach. Hitting the 2 GB wall mid-write produces a corrupt set rather than an error you can read, which is why this limit belongs in the planning, not the troubleshooting.

The Round Trip Warning, and When to Refuse the Format

Conversion damage is one-directional in a way worth internalizing: converting a shapefile back to GeoJSON does not restore what the shapefile cut. The ten-character field names stay cut, the dropped nested properties stay dropped, the datetimes stay date-only, and the split files must be re-merged by hand. A shapefile should therefore always be a copy at the end of a pipeline, never the archive in the middle of one: keep the GeoJSON (or a GeoPackage) as the data of record, and generate shapefiles as disposable exports for the recipients who demand them. When is refusal right? When the recipient's requirement is habit rather than law, which is often, a GeoPackage delivers everything the shapefile would, in one file, with long field names, real datetimes, mixed geometry handled as geometry collections, and no 2 GB ceiling in practical terms. The professional phrasing is an offer, not an argument: "I can send the shapefile set, or a GeoPackage that keeps the full field names and timestamps; which does your system prefer?" Half the time, the shapefile was never a requirement at all, just the oldest sentence in someone's data specification.

After: The Sixty-Second Audit

Whatever route you took, run these checks on the output before it leaves: feature count matches the source; every geometry type you expected exists as its own shapefile; field names survived as planned and no two source fields collapsed into one; the .prj names the CRS you intended; and a known feature's coordinates, opened in a fresh project, sit where they should. Sixty seconds, five checks, and the conversion is a deliverable instead of a rumor. And if the recipient can accept it, consider quietly offering a GeoPackage alongside: it is the modern single-file format with none of the four failure modes above, and half the agencies asking for shapefiles by habit will take it gladly when it simply works.

Related Guides

This guide does not stand alone. The GIS and open map data guides below take up the questions it leads into:

Frequently Asked Questions

How do I convert GeoJSON to shapefile in QGIS?

Load the GeoJSON layer, right-click it, and choose Export, Save Features As. Set the format to ESRI Shapefile, choose the output name, set the CRS (WGS 84 for like-for-like, or a projected system to reproject during export), and click OK. Then reload the output and compare feature counts and field names against the source.

What is the ogr2ogr command for GeoJSON to shapefile?

ogr2ogr -f "ESRI Shapefile" out.shp in.geojson converts directly. Add -t_srs followed by an EPSG code to reproject during conversion, and -nlt to force a geometry type when the source mixes types. Read the console warnings: they report truncated field names and dropped fields.

Why did my field names get cut off in the shapefile?

Because the shapefile's attribute table is a dBase file with a ten-character limit on column names. Names are truncated automatically, and two long names sharing the same first ten characters will collide. Rename fields to short, deliberate names before converting, and keep a mapping for the recipient.

Why is my shapefile missing or split into several files?

A shapefile is always a set of files (.shp, .shx, .dbf at minimum, plus .prj and .cpg) that must travel together, usually zipped. And because a shapefile holds exactly one geometry type, a GeoJSON file mixing points, lines, and polygons converts into one shapefile per type. Both behaviors are the format working as designed, not conversion errors.

Is GeoJSON in a specific coordinate system?

Yes. Per RFC 7946, GeoJSON coordinates are always longitude and latitude in WGS 84. If your file contains projected coordinates, it is nonconforming and already wrong before conversion. During conversion you may reproject the output shapefile to any CRS with QGIS, ogr2ogr's -t_srs, or GeoPandas' to_crs.

Photo credits: Markus Spiske (Pexels); Syirwan Ainu (Pexels). Photos are served from this site; follow the credit to the library page for the original.