A Shapefile to GeoJSON converter translates ESRI’s binary format into the open, web-friendly GeoJSON standard. Shapefiles power decades of GIS data but cannot be read directly by web maps or most modern tooling. This converter parses the geometry and attributes in your browser and emits a clean RFC 7946 FeatureCollection you can drop into Leaflet, Mapbox, QGIS, or a data pipeline.
How it works
The .shp file starts with a 100-byte header and then a list of records. Each record header carries a big-endian content length, while the geometry payload uses little-endian doubles. The converter reads each record’s shape type and decodes it: a Point becomes a GeoJSON Point, a multi-part line becomes a LineString or MultiLineString, and polygon rings are grouped using their signed area — clockwise rings are outer boundaries and counter-clockwise rings become holes — producing correct Polygon and MultiPolygon geometries.
If you include the .dbf, its dBASE header is read to learn each field’s name, type, and width. Records are decoded field by field, with numeric and float columns parsed into JSON numbers, and attached to the matching feature’s properties. A supplied .prj is reported so you know the source coordinate reference system.
Coordinate systems and when to reproject
GeoJSON (RFC 7946) assumes WGS84 longitude/latitude. The tool outputs coordinates unchanged, so if your .prj indicates a projected system — a UTM zone, British National Grid, or a state-plane system — the raw coordinates will not display correctly on a web map. You have two good options:
- Reproject the shapefile to EPSG:4326 before converting, using QGIS, GDAL’s
ogr2ogr, or any GIS software. - Convert first with this tool, then reproject the resulting GeoJSON using a tool that reads the source CRS from the
.prj.
Because everything is parsed client-side, the converter works fully offline once the page has loaded and keeps your data private — no geometry is ever uploaded.
What each shapefile component contributes
| File | Required | Purpose |
|---|---|---|
.shp | Yes | Binary geometry records |
.shx | No | Spatial index — not needed for sequential parsing |
.dbf | Recommended | Attribute table becomes GeoJSON properties |
.prj | Recommended | CRS description so you know if reprojection is needed |
.cpg | Optional | Code page for text fields in the .dbf |
Practical tips
- Large files — The browser can handle datasets of tens of thousands of features, but very large shapefiles (hundreds of MB) may be slow. For production pipelines,
ogr2ogr -f GeoJSONon the command line is faster. - Polygon winding — This converter follows RFC 7946 and assigns outer rings by clockwise area and inner rings (holes) counter-clockwise. If your source shapefile has inconsistent winding, some holes may appear as fills; QGIS can clean winding with the Fix Geometries tool.
- Multi-part geometries — A shapefile
PolyLinerecord with multiple parts becomes a GeoJSONMultiLineString, and aPolygonwith multiple outer rings becomes aMultiPolygon, preserving topological structure exactly.