OnlineMapMaker logo

Shapefile to GeoJSON Converter - SHP to GeoJSON in Few Clicks

Convert Shapefile files to GeoJSON format in a few clicks: upload a zipped shapefile, get a real RFC 7946 GeoJSON file back, and download it. Everything runs in your browser, nothing is uploaded. Open fullscreen version →

Rate this tool:
Advertisement
Advertisement
Loading converter…
Need assistance with your GIS project?Explore Our Services

Why convert a shapefile to GeoJSON

If you have ever asked "how do I convert a shapefile to GeoJSON?", the short answer is that a shapefile is not one file at all. What most people call "a shapefile" is actually a bundle of at least three separate files that share the same name and different extensions: `.shp` for the geometry, `.shx` for a positional index into that geometry, and `.dbf` for the attribute table. A real-world shapefile export often adds a `.prj` file for the coordinate reference system and a `.cpg` file for the text encoding. Open just the `.shp` file in a text editor and you get binary noise; open just the `.dbf` and you get attributes with no shapes to attach them to.

GeoJSON, by contrast, is one self-contained JSON file, defined by a single specification (RFC 7946), and it fixes the coordinate reference system to WGS84 longitude and latitude. That single-file, single-CRS design is exactly why so many web maps, JavaScript libraries, and modern GIS APIs expect GeoJSON as input rather than a shapefile bundle. Converting shapefiles to geojson is usually the first step before a dataset can be dropped into Leaflet, Mapbox GL, a GitHub-rendered map preview, or almost any other browser-based mapping tool.

This tool exists to make that first step painless. Instead of installing GDAL, opening desktop GIS software, or writing a Python script just to convert one file, you zip your `.shp` / `.shx` / `.dbf` (and `.prj`, if you have it) together, drop the zip in your browser, and get back a working `.geojson` file in a few clicks. The conversion runs entirely client-side, so the tool works the same for ten features or a hundred thousand, and your data is never sent anywhere.

Advertisement
Advertisement

The Shapefile format: history and structure

The shapefile format was published by ESRI (Environmental Systems Research Institute) in July 1998 in a document called the "ESRI Shapefile Technical Description". Despite being nearly three decades old and lacking native support for attribute field names longer than 10 characters, multiple geometry layers per file, or Unicode by default, it remains one of the most widely used vector GIS formats in government, utility, and academic datasets worldwide, largely because of how early and how thoroughly it was adopted before more modern formats existed.

The .shp file starts with a fixed 100-byte header: bytes 0 to 3 are a big-endian "file code" that is always the integer 9994, bytes 24 to 27 give the file length in 16-bit words (big-endian), bytes 28 to 31 give the shapefile version (little-endian, always 1000), bytes 32 to 35 give the shape type as an integer code (1 = Point, 3 = PolyLine, 5 = Polygon, 8 = MultiPoint, with +10 or +20 variants for Z and M coordinate values), and bytes 36 to 67 give the bounding box of the entire file as four little-endian doubles: Xmin, Ymin, Xmax, Ymax. After that header, the file is a sequence of variable-length records, each with its own small header naming the record number and content length before the geometry bytes themselves.

The .dbf file is a dBase III / dBase IV table: a header block describing every field (name, type, byte length, decimal count), followed by one fixed-width record per row. Row order in the .dbf matches record order in the .shp file exactly, position for position, since there is no explicit foreign key between them. The .shx file exists purely as a shortcut: it stores an 8-byte (offset, length) pair per record so a reader can jump straight to any shape without scanning every preceding record, which matters far more for a 500 MB shapefile than for a small one.

One structural quirk carries directly into the conversion logic: a shapefile polygon record has no concept of "this ring is a hole in that ring." It is simply a flat list of closed rings. The convention (per the spec) is that clockwise-wound rings are outer boundaries and counter-clockwise-wound rings are holes, and a reader is expected to work out which hole belongs inside which outer ring itself. GeoJSON polygons follow the same winding convention (RFC 7946 recommends, though does not strictly require, the same rule), but a Shapefile-to-GeoJSON converter still has to walk every ring, classify it, and reassemble the nesting before it can emit a valid Polygon or MultiPolygon geometry.

Step-by-step guide: how to convert shp to geojson

Shapefile to GeoJSON converter with the Choose File button and a zipped shapefile selected
Step 1

Zip your `.shp`, `.shx`, and `.dbf` files together (include the `.prj` too, if you have one), then choose that zip file in the converter, or click "Try sample" to load a small ready-made shapefile. The shapefile is parsed immediately and previewed on the map as a gray "Source shapefile" layer.

Shapefile loaded into the converter, ready to convert to GeoJSON
Step 2

The Layers panel lists the source shapefile with its feature count. Check the map to confirm the right data loaded, then click "Convert to GeoJSON" whenever you are ready.

Conversion result panel showing feature count, geometry types, bounding box, and file size
Step 3

A second "Converted GeoJSON" layer is added on top of the source, and a summary appears: how many features were converted, which geometry types were found, the bounding box, the attribute columns, and the resulting GeoJSON file size.

Map preview of the converted shapefile features with the basemap toggle switched on
Step 4

Use the checkboxes in the Layers panel to toggle the source and converted layers independently, and turn on "Show basemap" if you want street-map context underneath both.

Download button for the converted .geojson file
Step 5

Click "Download converted.geojson" to save the finished, standards-compliant GeoJSON file to your computer.

Advertisement
Advertisement

Six real-world use cases

Where converting shapefiles to geojson actually comes up in day-to-day GIS work.

  1. Publishing government open data on the web. Many municipal, state, and national open-data portals still ship parcel, zoning, and boundary datasets as shapefiles. Converting shapefiles to geojson turns that download into something a web map or a JavaScript app can load directly, with no server-side processing.
  2. Loading survey or field data into a web map. Field GPS units and older desktop GIS workflows frequently export shapefiles. A quick shp to geojson conversion is often the only step standing between a surveyor's output and a shareable Leaflet or Mapbox GL map.
  3. Preparing data for GitHub or GitLab map previews. GitHub renders `.geojson` files as an interactive map automatically, but it does not render shapefiles at all. Converting a shapefile before committing it is the difference between a rendered map and four unreadable binary files in a repository.
  4. Feeding data into JavaScript mapping libraries. Leaflet, Mapbox GL JS, OpenLayers, and deck.gl all consume GeoJSON natively. None of them can read a shapefile directly in the browser, so a shp to geojson converter is a required step in any client-side mapping pipeline that starts from shapefile data.
  5. Migrating legacy GIS archives to modern formats. Organizations retiring old desktop GIS systems often hold years of shapefile archives. Converting shapefiles to geojson (or onward to GeoParquet or GeoPackage) is usually the first migration step, since GeoJSON is readable by virtually every modern tool.
  6. Quick one-off checks without installing desktop GIS. Sometimes you just need to see what is inside a `.shp` file someone emailed you. Converting it to GeoJSON and previewing it on a map is faster than installing QGIS or ArcGIS for a single file.

The conversion algorithm, step by step

Converting a shapefile to GeoJSON is not a single operation but a small pipeline of well-defined parsing and geometry-reconstruction steps. Here is exactly what happens to your data, in order.

1. Unzip and locate the matching file set

The uploaded .zip is decompressed in memory, and the converter groups files by their shared base name to find a matching .shp / .shx / .dbf triplet (plus an optional .prj and .cpg). If a zip contains more than one such triplet, it is treated as a multi-layer shapefile export and each layer is converted independently.

2. Parse the fixed 100-byte `.shp` header

The header is read first to confirm the file code equals 9994, to read the shape type (which tells the parser what record structure to expect next), and to read the file-level bounding box. The layout of the fields that matter for conversion is:

Bytes 0-3    File code           big-endian int, always 9994
Bytes 24-27  File length         big-endian int, in 16-bit words
Bytes 28-31  Version             little-endian int, always 1000
Bytes 32-35  Shape type          little-endian int (1=Point, 3=PolyLine, 5=Polygon, 8=MultiPoint)
Bytes 36-67  Bounding box        4 little-endian doubles: Xmin, Ymin, Xmax, Ymax

Everything after byte 100 is read as a stream of variable-length records, each prefixed by its own small header giving the record number and content length in 16-bit words, which is then converted to a byte count by multiplying by two.

3. Reconstruct rings into Polygon and MultiPolygon geometries

For Polygon-type records, every ring in the record is read as a flat array of (x, y) pairs. The converter then computes the signed area of each ring using the shoelace formula, area = 0.5 * Σ(x[i] * y[i+1] - x[i+1] * y[i]). A positive result (in the shapefile's clockwise-positive convention) marks an outer ring; a negative result marks a hole. Each hole ring is then matched to the smallest outer ring whose bounding box fully contains it, and the two are combined into a single GeoJSON Polygon's coordinates array, with the outer ring first and every hole ring after it. When a record contains more than one outer ring, the result becomes a MultiPolygon instead.

4. Reproject coordinates and attach attributes

If a .prj file is present and its coordinate reference system is not already WGS84, every coordinate pair produced in the previous step is reprojected to WGS84 longitude/latitude, since that is the coordinate system RFC 7946 requires for valid GeoJSON. In parallel, the .dbf table is parsed field by field, and record i in the .dbf is attached as the properties object of the geometry built from record i in the .shp file, since the two files are matched purely by position, not by any explicit key.

The final step wraps every converted geometry and its properties into a GeoJSON Feature, collects every feature into a single FeatureCollection, and serializes that structure to text, ready to download as a .geojson file. Because every step above is a deterministic, well-defined transformation, converting the same shapefile twice always produces byte-identical GeoJSON output.

Advertisement
Advertisement

The GIS libraries behind shapefile conversion

A shp to geojson converter is only as good as the shapefile parser underneath it. Here is what actually does the work, in this tool and elsewhere.

  • shpjs: The engine behind this tool. shpjs is a pure-JavaScript library that unzips the archive, parses the `.shp` binary geometry and `.dbf` attribute table, reprojects coordinates using `.prj` data when present, and assembles the result into GeoJSON, all without leaving the browser or a Node.js process.
  • GDAL / OGR (ogr2ogr): The C/C++ library that underlies most desktop and server-side GIS software. The command `ogr2ogr -f GeoJSON output.geojson input.shp` is the de facto standard way to convert shapefiles to geojson from the command line, and it is the same engine QGIS calls internally when you use its "Export Features" dialog.
  • Fiona and GeoPandas: Python's geospatial file I/O stack. Fiona wraps GDAL/OGR directly, and GeoPandas builds on Fiona so that `gpd.read_file('data.shp')` followed by `gdf.to_file('data.geojson', driver='GeoJSON')` is one of the most common ways developers convert shapefiles to geojson inside a data pipeline.
  • Mapshaper: A widely used command-line and browser-based tool (by Matthew Bloch) that reads shapefiles with its own parser and can simplify geometry while converting, useful when a shapefile is too detailed for a web map and needs both conversion and simplification in one pass.
  • QGIS and ArcGIS: Both desktop GIS applications can open a shapefile natively and export it as GeoJSON through a menu action, QGIS's "Export Features" and ArcGIS's "Feature Class to GeoJSON" or similar tools, both of which call GDAL/OGR or an equivalent library underneath the user interface.

All of these tools agree on the same underlying shapefile specification and the same GeoJSON output format, so a file converted by any of them should be structurally equivalent. The difference is where the work happens: GDAL, Fiona, and desktop GIS software all run on a machine with something installed, while this tool's shpjs-based engine runs directly in your browser tab, which is why no installation and no file upload to a server are ever required here.

Technical questions and answers

Ten common questions about how do I convert a shapefile to GeoJSON, answered directly.

1. How do I convert a shapefile to GeoJSON?

Put the .shp, .shx, and .dbf files (plus .prj if you have it) into a single .zip archive, upload that zip to this converter, and click "Convert to GeoJSON". The tool reads the shapefile's binary geometry, matches it to the attribute table, and produces a standards-compliant .geojson file you can download immediately, all inside your browser.

2. Why does this tool ask for a zip file instead of the .shp file directly?

A .shp file alone only contains geometry, with no attributes and, critically, no field describing what each shape actually represents. A valid shapefile is a set of at least three files (.shp, .shx, .dbf) that must be read together, so this converter, like every other shp to geojson converter, needs all of them at once, and a zip is the simplest way to hand over a matched set.

3. Is this shp to geojson conversion free, and is there a file size limit?

Yes, it is completely free with no sign-up. There is no artificial file size cap, though very large shapefiles (several hundred MB) will take longer to parse since everything happens on your own device rather than a server.

4. Does the converter preserve my attribute data?

Yes. Every field in the .dbf table is read and attached to its matching feature as a GeoJSON properties object, preserving field names and values, including numbers, text, and dates.

5. What happens to the coordinate reference system?

If your zip includes a .prj file, the converter reads the coordinate reference system it describes. GeoJSON per RFC 7946 is always in WGS84 longitude/latitude, so if the source shapefile uses a different projection (a common case for national grid systems), the coordinates are reprojected to WGS84 during conversion. If no .prj file is present, the coordinates are assumed to already be in WGS84.

6. Can it handle Polygon shapefiles with holes correctly?

Yes. Shapefile polygon records store rings as a flat list with no explicit parent-child relationship, relying on ring winding order to distinguish outer boundaries from holes. The converter classifies every ring by its signed area, reassembles holes into their correct parent ring, and outputs proper GeoJSON Polygon or MultiPolygon geometries.

7. What geometry types are supported?

Point, MultiPoint, PolyLine (converted to LineString or MultiLineString), and Polygon (converted to Polygon or MultiPolygon), including their Z (elevation) and M (measure) variants. Null-type records are skipped, since they carry no geometry to convert.

8. Can a shapefile with more than one layer be converted?

A single .shp file always holds exactly one geometry layer, so if your zip contains multiple .shp files (a multi-layer export), each is converted separately and clearly labelled in the result, so you can tell which features came from which original shapefile.

9. Why do some text attributes look garbled after conversion?

The .dbf format stores text using a specific code page (character encoding), and older shapefiles do not always include a .cpg file stating which one. When no encoding is declared, the converter falls back to a common default; if your source data used an unusual regional encoding, some accented characters may need manual correction after conversion.

10. Is my shapefile uploaded to a server?

No. Unzipping the archive, parsing the binary .shp geometry, reading the .dbf attribute table, and assembling the final GeoJSON all happen locally in your browser using JavaScript. Your file never leaves your device.

Conversion runs entirely in your browser using shpjs. No file is ever uploaded to a server. Map tiles © OpenStreetMap contributors, drawn with Protomaps (hosted by KONAKTIVE), with CARTO as the fallback.

Muhammad Gulraiz Khan, GIS Expert and Founder of KONAKTIVE and OnlineMapMaker.com

About the Author

Muhammad Gulraiz Khan

GIS Expert & Consultant · Founder, KONAKTIVE

Muhammad Gulraiz Khan is a GIS expert with over a decade of professional experience delivering geospatial solutions for the energy sector, including projects for the World Bank, the International Finance Corporation (IFC), and USAID. He built OnlineMapMaker.com to make professional-grade mapping tools free and accessible to everyone.

Advertisement
Advertisement