# GeoJSON to Shapefile converter

> Hand your GeoJSON to someone who works in ArcGIS: get a zip with the .shp, .shx, .dbf, .prj and .cpg files, one layer per kind of shape. Free, and no account needed.

Open the tool: https://spatibase.com/tools/geojson-to-shapefile/

The Spatibase GeoJSON to Shapefile converter writes an ESRI shapefile from a GeoJSON file in your web browser, with its own writer. What it produces:

- **A zip ArcGIS and QGIS open.** Point, polyline and polygon layers as needed, each with a WGS 84 `.prj` and a `.cpg` that says UTF-8.
- **Columns with real types.** Numbers become numeric fields and `true`/`false` logical ones; names are cut to 10 characters, and every rename is listed.
- **Your data stays local.** Read and written on your computer, up to 50 MB, with no account.

## What it does
- Convert GeoJSON to an ESRI shapefile in a .zip
- One layer per kind of shape: points, lines, areas
- Numeric, logical and text DBF fields from the property values
- Outer rings clockwise and holes counter-clockwise, as ESRI requires
- UTF-8 attribute text with a .cpg file
- A WGS 84 .prj in every layer
- Runs in the browser: nothing is uploaded

## How to convert GeoJSON to a shapefile
1. Save the GeoJSON as a file: an API response, a geojson.io drawing (Save → GeoJSON) or an Overpass Turbo export.
2. Drop it on the box above, or press Choose a file. The sample mixes 5 places, a walking route and 3 areas, so it gives all three layers.
3. Read the notes under the map: renamed fields, values cut at 254 bytes and dropped altitude are all counted there.
4. Press Download shapefile (.zip). The sample comes out as `barcelona.zip` with `barcelona_points`, `barcelona_lines` and `barcelona_areas` inside, 15 files in all.
5. Send the zip as it is: ArcGIS Online and most portals take a zipped shapefile. For ArcGIS Pro or QGIS, unzip it and add the `.shp` files.

## Formats and limits
- **Opens:** .geojson or .json, up to 50 MB. Other map files (KML, KMZ, GPX, GeoJSON, shapefile, CSV) convert too.
- **Downloads:** Shapefile, 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/geojson-to-shapefile/?sample=1
- Download the sample file (the one Open a sample opens): https://spatibase.com/tools/samples/barcelona.geojson

## What happens to your GeoJSON in a shapefile
| What | What happens |
|---|---|
| Points, lines and areas | Kept, one layer per kind: Point and MultiPoint in `_points`, LineString and MultiLineString in `_lines`, Polygon and MultiPolygon in `_areas`. A file with one kind gives one layer named after the file. |
| GeometryCollection | Split: each part goes to its layer and carries the same attributes. The notes count these features. |
| Polygon holes | Kept, with every ring turned to ESRI’s order: outer clockwise, holes counter-clockwise. |
| Number properties | A numeric (`N`) field with as many decimals as the values need. A field that mixes numbers and text becomes text. |
| `true`/`false` properties | A logical (`L`) field. A missing value is written as unknown, not as false. |
| Text, dates and nested values | Text (`C`) fields. Objects and arrays are written as JSON text; anything over 254 bytes is cut, with a count in the notes. |
| Property names | Cut to 10 characters, accents dropped, other symbols turned into `_`, and kept unique: `stroke-width` → `stroke_wid`. |
| Style keys such as `marker-color` | Kept as ordinary fields, since in a GeoJSON they may be your data. |
| Altitude | Dropped: the layers are 2D. The notes say how many coordinates had one. |
| Feature `id` and features without geometry | Not written. Only `properties` become columns, and a feature without a location has no record to go in. |

## From JSON values to dBASE columns
**GeoJSON types each value; a shapefile types each column.** In GeoJSON, one feature’s `rating` can be `4.5` and the next one’s `"n/a"`. The `.dbf` beside a shapefile needs one type per column, decided before any row is written.

So the converter looks at every value of a property across all features of a layer and picks:

- **Logical (L)** when every filled value is `true` or `false`.
- **Numeric (N)** when every filled value is a plain number of at most 20 characters. The width and decimals fit the longest value.
- **Text (C)** for everything else, up to 254 bytes. Accented and non-Latin letters take 2–4 bytes each, so the limit in letters is lower.

**Each layer gets its own table.** The points layer has the columns its points use, and the areas layer those of its areas. A property only your lines have doesn’t show up as an empty column on the points.

**Why rings get turned around.** RFC 7946 asks for counter-clockwise outer rings; the shapefile spec wants the opposite and uses the direction to tell outer rings from holes. The writer checks every ring and reverses the ones that point the wrong way.

## Write a shapefile from GeoJSON in Python
geopandas, which runs on GDAL, writes shapefiles. One shapefile holds one kind of shape, so split the data first:

```python
import geopandas as gpd

gdf = gpd.read_file("places.geojson")
kinds = gdf.geom_type.str.replace("Multi", "")  # Point, LineString, Polygon
for kind in kinds.unique():
    gdf[kinds == kind].to_file(f"places_{kind.lower()}.shp", encoding="utf-8")
```

**On the command line,** `ogr2ogr -f "ESRI Shapefile" places.shp places.geojson -lco ENCODING=UTF-8` converts a file with one kind of shape. Add `-nlt PROMOTE_TO_MULTI` when singles and multis are mixed, such as Polygon and MultiPolygon.

**Check before you send.** `ogrinfo -so -al places_point.shp` prints the layer’s geometry type, feature count and fields, which catches a broken file faster than opening it in ArcGIS.

## Frequently asked questions
### How do I convert GeoJSON to a shapefile in QGIS?
Drag the GeoJSON onto the map. If it mixes points, lines and polygons, QGIS asks which sublayers to add: take all of them. Then right-click each layer, choose Export → Save Features As, pick ESRI Shapefile and set the encoding to UTF-8.

### Do number and true/false properties keep their types in the shapefile?
Yes, when the property is consistent. A property whose values are all numbers becomes a numeric field, and one that is all true or false becomes a logical field. As soon as one feature holds text in that property, the whole column is written as text.

### What happens to nested objects and arrays in GeoJSON properties?
They are written as JSON text in a text field, such as {"open":"9-17"}. A shapefile column can’t hold a structure, and the text is cut at 254 bytes. Flatten the values into separate properties before converting if you need them as columns.

### Can I make a shapefile from GeoJSON in JavaScript?
Yes, but test the output. In our tests @mapbox/shp-write 0.4.3 merged separate lines into one record, garbled accented text and dropped MultiPoints, so this page uses its own small writer. On a server, GDAL’s ogr2ogr or geopandas is the safe choice.

### Will accented and non-Latin names survive in ArcGIS?
Yes. The attribute table is written in UTF-8, and each layer has a .cpg file that says so. ArcGIS 10 and later, ArcGIS Pro, QGIS and GDAL read the .cpg, so names like Museu Marítim stay intact. Keep the .cpg next to the .dbf when you move the files.

### Is the GeoJSON sent anywhere to make the shapefile?
No. The shapefile is built by JavaScript in your browser tab, and the file stays on your computer. Spatibase never receives it; only the background map tiles come from the internet.

## 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/).
