OnlineMapMaker logo

GeoJSON to Shapefile Converter

Turn a GeoJSON file into a zipped Esri Shapefile that opens in QGIS and ArcGIS. Everything runs in your browser, nothing is uploaded. Open fullscreen version →

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

Why convert GeoJSON to a Shapefile

GeoJSON is the format most web maps and APIs give you. But a lot of desktop GIS work, city offices, utility companies and older ArcGIS projects still expect a Shapefile. If you try to send a .geojson file to one of those people, the usual answer is "can you give me a shapefile?"

The two formats are built differently, so the conversion is more than a rename. A Shapefile is really five or six files that belong together. The geometry goes in the .shp file, an index goes in the .shx file, the attribute table goes in the .dbf file, and the coordinate system goes in the .prj file. A Shapefile can also hold only one kind of geometry, while a GeoJSON file can mix points, lines and polygons freely. This tool handles those differences for you.

You drop in a GeoJSON file and get back one .zip file. If your data mixes geometry types, the zip contains one Shapefile for points, one for lines and one for polygons, so no feature is lost. Long property names are shortened to the 10 characters the format allows, and the result panel tells you exactly which names changed. The conversion runs in your browser, so your data never leaves your computer.

Advertisement
Advertisement

The Shapefile format: history, structure and limits

Esri introduced the Shapefile in the early 1990s for its ArcView desktop software. It was meant as a simple, fast format that could be read without a database. In July 1998 Esri published a public technical description, and since then almost every GIS program, free or paid, can read and write it. That is the main reason the format is still everywhere, more than 30 years later.

The attribute table inside a Shapefile uses the dBase III file format, which is even older. This is where the best-known limits come from. Field names can have at most 10 characters, a text value can have at most 254 bytes, and a field cannot hold nested data. A .dbf file also has no real type for dates with times, so many tools store them as text.

The geometry file has its own limits. The offsets inside it are 32-bit numbers, so a single .shp or .dbf file cannot be larger than about 2 GB. Each file holds exactly one geometry type, such as points, polylines or polygons. In a polygon, the outer ring must run clockwise and each hole must run counterclockwise. GeoJSON (RFC 7946, published in 2016) uses the opposite order for outer rings, so a correct converter has to turn the rings around.

None of this makes the Shapefile a good format for new projects. GeoPackage and GeoParquet fix most of these limits. But the Shapefile is still the format that every office, every agency and every GIS course knows, so being able to produce a clean one quickly is a useful skill.

Step-by-step guide

GeoJSON to Shapefile converter with the Choose File button and sample link visible
Step 1

Choose a .geojson file from your computer, paste GeoJSON text into the box, or click "Try sample" to load a small German example with points, lines and polygons.

GeoJSON text loaded into the converter with a layer name, ready to convert
Step 2

Check the layer name. It becomes the name of the files inside the zip and of the zip itself. Then click "Convert to Shapefile". Typical files finish in a fraction of a second.

Conversion result panel listing one Shapefile per geometry type, with the bounding box and zip size
Step 3

A summary shows one line per Shapefile (points, lines, polygons), the bounding box, the property columns, and any field names that had to be shortened.

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

The features are drawn on the map so you can check that the right data was converted. The map starts blank. Tick "Show basemap" if you want street tiles under the data.

Download button for the zipped Shapefile
Step 5

Click the download button to save the .zip file. Unzip it and open the .shp file in QGIS, ArcGIS or any other GIS program.

Advertisement
Advertisement

Six real-world use cases

Situations where people need a Shapefile even though their data started as GeoJSON.

  1. Sending data to an ArcGIS user. A colleague or client works in ArcGIS Desktop and asks for a Shapefile. You export GeoJSON from a web tool and convert it here in a few seconds.
  2. Submitting data to a government office. Many planning departments and permit offices only accept Shapefiles. A zip with the .shp, .shx, .dbf and .prj files is exactly what their upload form wants.
  3. Using web map data in older software. Survey tools, CAD add-ons and some engineering programs cannot read GeoJSON. They can almost always import a Shapefile.
  4. Cleaning up an API download. You pulled features from a web API and want to look at them in a desktop GIS. Converting to Shapefile gives you a standard file with a proper .prj, so the layer lines up with your other data.
  5. Teaching and coursework. Many GIS courses still hand out Shapefile exercises. Students can export their own GeoJSON data and convert it here without installing GDAL.
  6. Handing data to a print or cartography team. Map designers often work in tools that import Shapefiles by default. Splitting mixed data into separate point, line and polygon files makes it easier for them to style each layer.

Technical questions and answers

Ten common questions about how this converter works, answered directly.

1. What files are inside the zip I download?

For each geometry type you get five files with the same base name. The .shp file has the shapes, the .shx file is an index of where each shape starts, the .dbf file is the attribute table, the .prj file names the coordinate system, and the .cpg file says the text is UTF-8. Keep them together. A .shp file on its own is not a complete Shapefile.

2. My GeoJSON has points, lines and polygons. What happens?

A Shapefile can only hold one geometry type, so the converter writes one Shapefile per type and puts all of them in the same zip. The files are named with a suffix, for example converted_points, converted_lines and converted_polygons. If your data has only one type, there is no suffix.

3. Which coordinate system does the output use?

WGS 84 longitude and latitude (EPSG:4326). GeoJSON is defined in this system, so the numbers are copied as they are and a matching .prj file is written. If your GeoJSON uses another system in a non-standard way, reproject it to WGS 84 first, because this tool does not do reprojection.

4. Why were some of my field names changed?

The dBase format inside a Shapefile allows only 10 characters per field name. A name like population_estimate becomes population, and when two names would end up the same, a number is added, for example a_very_lon and a_very_lo1. Characters other than letters, digits and underscores are replaced with an underscore. The result panel lists every change.

5. What happens to numbers, true/false values and text?

Whole numbers and decimals become numeric fields, with the decimal places set to the most that any feature uses. True and false values become logical fields. Text becomes a character field as wide as the longest value, up to 254 bytes. If a property mixes types, for example numbers in some features and text in others, the whole column is stored as text.

6. What happens to nested objects and arrays in properties?

A Shapefile table is flat, so an object or array is written as a JSON text string in a character field. You can read it back with any JSON tool. Values longer than 254 bytes are cut, and the result panel tells you how many were cut.

7. Are the polygon holes and the ring direction correct?

Yes. The converter reads the signed area of every ring and turns it around when needed, so outer rings run clockwise and holes run counterclockwise, as the Shapefile specification requires. MultiPolygon features are written as one record with several outer rings and their holes.

8. What about 3D coordinates and features without geometry?

Only X and Y are written, so any height value (Z) is dropped, and the result panel says so. Features with a null or unusable geometry are skipped, and the panel shows how many. Their properties are not written either, because a Shapefile row needs a shape.

9. Does this work for large files?

It works well for files of several tens of megabytes, because the whole job runs in your browser memory. Very large files may be slow or run out of memory on a phone. A single Shapefile also cannot grow past about 2 GB, which is a limit of the format itself.

10. Is my GeoJSON file uploaded to a server?

No. Parsing, writing the five files and zipping them all happen inside your browser. Your file never leaves your device, and no part of the conversion touches a server.

How the Shapefile is built, byte by byte

The conversion has no guessing in it. Every part of the output follows a fixed byte layout from the Esri specification. Here is what the tool does with your data.

1. One geometry family per file

First the tool reads every feature and sorts its geometry into one of three groups: points (Point, MultiPoint), lines (LineString, MultiLineString) and polygons (Polygon, MultiPolygon). A GeometryCollection is split into its parts, and each part goes to its own group. Each non-empty group becomes its own Shapefile with its own shape type code: 1 for a point, 8 for a multipoint, 3 for a polyline and 5 for a polygon.

2. The .shp, .shx and .dbf layout

The .shp file starts with a 100-byte header. It contains the file code 9994, the version 1000, the shape type and the bounding box. After that comes one record per feature. Each record has an 8-byte header (record number and length, both big-endian) and then the content, whose size depends on the shape. A polyline or polygon with p parts and n points needs 4 + 32 + 4 + 4 + 4p + 16n bytes of content:

.shp header     = 100 bytes: 9994 | file length | 1000 | shape type | bbox
record          = 8-byte header + content   (record number, length in 16-bit words)

Point           = 4 + 16                                    = 20 bytes
MultiPoint(n)   = 4 + 32 + 4 + 16n
PolyLine/Polygon(p parts, n points) = 4 + 32 + 4 + 4 + 4p + 16n   (r = records, f = fields)

.shx            = 100 + 8r
.dbf            = 32 + 32f + 1  |  r records of (1 + sum of field widths)  |  0x1A

The size is exact, so the tool can allocate the buffer once and write every number with a DataView. A simple line with 3 points and 1 part takes 4 + 32 + 4 + 4 + 4 + 48 = 96 bytes of content, plus 8 bytes of record header. The .shx file repeats the offset and length of each record, which is why it is always 100 + 8r bytes.

3. Turning polygon rings around

The direction of a ring is found with the shoelace formula. For points (x, y) in order, the signed area is the sum of (x_prev + x) * (y_prev - y) divided by 2. A negative result means clockwise. GeoJSON wants outer rings counterclockwise, and a Shapefile wants them clockwise, so any outer ring with a positive area is reversed. Holes get the opposite rule. Rings are also closed if the first and last point differ.

4. Sizing the attribute table

The .dbf header is 32 + 32f + 1 bytes, and each row is one space character (the "not deleted" flag) plus the width of every field. To pick a width, the tool measures every value. For text it uses the longest UTF-8 byte length (at most 254). For numbers it uses the most digits before the decimal point, plus the most decimal places found, plus one for the point and one for a minus sign if any value is negative. A number is written with toFixed, padded on the left with spaces to the field width.

Because every size is calculated before anything is written, the output is deterministic: the same GeoJSON converted twice gives the same .shp, .shx and .dbf bytes. Only the date stored in the .dbf header changes from day to day.

Conversion runs entirely in your browser. The Shapefile files are written by this site's own code and packed with JSZip. No file is ever uploaded to a server. Optional base maps © 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