Shapefile to GeoJSON converter
Turn a zipped shapefile into an RFC 7946 GeoJSON FeatureCollection in WGS 84, ready for Leaflet, MapLibre or an import. Free, and no account needed.
Convert Shapefile to GeoJSON online, in your browser
The Spatibase Shapefile to GeoJSON converter reads an ESRI shapefile (zipped, or loose .shp, .dbf, .prj and .cpg) and writes an RFC 7946 FeatureCollection in your web browser. What it takes care of:
- A GeoJSON any web map can draw. Projected data is reprojected to WGS 84 from the
.prj, with the datum shift ESRI files leave out for ED50, DHDN, Amersfoort and NAD27. - Attributes with their types. Numbers stay numbers, and text is decoded from the
.cpgor the.dbfheader, so accents survive. - Nothing is uploaded. Files up to 50 MB, free, no account.
How to convert a shapefile to GeoJSON
- Get the shapefile as a .zip, the way open data portals and ArcGIS Online hand it out, or find the
.shp,.dbf,.prjand.cpgthat share one name. - Drop the zip on the box above, or press Choose a file and select the loose parts together. The sample is Barcelona in ETRS89 / UTM 31N (EPSG:25831), so you can watch it being reprojected.
- Check that the map shows your data in the right place. The notes flag a missing
.prjor.dbfand old datums. - Press Download GeoJSON, or Copy GeoJSON to paste it into geojson.io or your code.
- Use it in Leaflet, MapLibre or OpenLayers as it is, or import it into a Spatibase project, which takes GeoJSON but not shapefiles.
What the GeoJSON keeps from your shapefile
| What | What happens |
|---|---|
| Geometry | Points, polylines and polygons become Point, LineString and Polygon, or their Multi types for records with several parts. Polygon holes stay holes. |
| Coordinate system | Always WGS 84 longitude and latitude, as RFC 7946 requires. There is no crs member. |
| Numeric fields | Numbers in the GeoJSON, not strings. An empty number is null. |
| Date fields | Text such as 1897-04-20, because JSON has no date type. |
| Text fields | Decoded from the .cpg, or from the code page in the .dbf header for old ArcGIS exports without one. |
| Field names | As in the .dbf, including any 10-character cut the shapefile made. |
| Several layers | One FeatureCollection. Each feature gets a folder property with its layer’s file name, unless the data already has one. |
| Index and metadata files | Ignored: .shx, .sbn, .sbx, .qix and .shp.xml hold nothing the GeoJSON needs. |
Why a shapefile has to be reprojected to become GeoJSON
GeoJSON means WGS 84. RFC 7946, the GeoJSON standard, fixes coordinates as longitude, then latitude, in degrees, and dropped the old crs member. Leaflet, MapLibre, Mapbox and geojson.io all assume it.
Official shapefiles are projected. Most downloads come in the publisher’s grid: ETRS89 / UTM in much of Europe, State Plane feet in the US, British National Grid in the UK. Copied across as they are, the Barcelona sample’s first point would read [431758, 4581911], and a web map would draw nothing.
Two quieter problems often slip through a conversion:
- Old datums move things quietly. ESRI
.prjfiles don’t carry the shift between an old datum and WGS 84. A plain reprojection leaves ED50 data about 150 m off, DHDN about 200 m and NAD27 about 30 m. The converter adds the shift for those four, and names any other old datum in a note. - Broken accents come from the .dbf. Older ArcGIS exports store text in a Windows code page and leave out the
.cpg. Read as UTF-8, “Família” turns into “Fam�lia”. The converter checks whether the text is valid UTF-8 and, if not, uses the code page written in the.dbfheader.
Read a shapefile into GeoJSON in JavaScript
shpjs, the open-source library this page builds on, does it in the browser and in Node.js. It unzips the shapefile, reads the .prj and reprojects with proj4.
import shp from 'shpjs'
// a zipped shapefile: a File from <input type="file">, or a fetch() response
const geojson = await shp(await file.arrayBuffer())
// a zip with several .shp files gives an array: one FeatureCollection per layer
const layers = Array.isArray(geojson) ? geojson : [geojson]
for (const fc of layers) console.log(fc.fileName, fc.features.length)Two gaps to cover yourself. shpjs doesn’t add the missing datum shift, so ED50, DHDN, Amersfoort and NAD27 data come out 30–200 m off. And a .prj that proj4 can’t read makes shp() throw an error with no message, so catch it and tell people what went wrong.
On the command line, ogr2ogr -f GeoJSON -t_srs EPSG:4326 out.geojson /vsizip/in.zip does it with GDAL. Leave out -t_srs and GDAL keeps the projected metres, with a crs member most web maps ignore.
Questions about converting Shapefile to GeoJSON
Why are my GeoJSON coordinates huge numbers like 431758, 4581911?
They are still in the shapefile’s projected grid, in metres or feet, so the converter you used didn’t reproject them. GeoJSON needs longitude and latitude in degrees. Convert the shapefile here with its .prj included, or with ogr2ogr and -t_srs EPSG:4326.
Do I need the .prj file to convert a shapefile to GeoJSON?
Yes, unless the data is already in WGS 84. The .prj says which grid the coordinates are in. Without it, coordinates that look like degrees are read as WGS 84 with a note, and coordinates that look like metres stop the conversion with a message asking for the .prj.
How do I export a shapefile as GeoJSON in QGIS?
Right-click the layer, choose Export → Save Features As, pick GeoJSON as the format and set the CRS to EPSG:4326 - WGS 84. QGIS otherwise keeps the layer’s own CRS, which gives projected coordinates.
How do I convert a shapefile to GeoJSON in Python?
With geopandas: gpd.read_file("data.zip").to_crs(4326).to_file("data.geojson", driver="GeoJSON"). geopandas reads the zip directly. The to_crs(4326) step is the one people forget.
Why do accented letters look wrong after converting?
The .dbf holds text in an older Windows code page and the .cpg file that names it is missing, so the text was read as UTF-8. This converter detects that from the .dbf header. Elsewhere, add a .cpg containing 1252 next to the .dbf and convert again.
Can I import a shapefile into Spatibase?
Yes. Spatibase imports the shapefile itself, as a .zip or the .shp, .dbf, .shx and .prj files together: in a project choose Import data, or start a new project from your data. From this page it’s one step: press Save to Spatibase (free). The import wizard reads the attribute columns like spreadsheet columns and can create fields from them, up to 10,000 features per file.
Moving the places into Spatibase? Read how to import your data. Need another pair of formats? The GIS file converter converts between all of them.