GpsField Logo
GpsField
GIS Tools8 min read

Convert Shapefile to GeoJSON: Fast, Accurate

Need to convert Shapefile to GeoJSON? Follow fast, accurate steps with GpsField’s in‑browser converter, plus CRS, attributes, and QA tips for professionals.

G

GpsField

Field GIS Specialist · 8 min read

Field workstation converting shapefile to GeoJSON for farm and survey boundaries

Convert Shapefile to GeoJSON: Fast, Accurate

How to Convert Shapefile to GeoJSON (Step‑by‑Step, With Field‑Ready Tips)

If you need to turn a Shapefile into GeoJSON for a web map, equipment display, or a field workflow, you can do it entirely in your browser with GpsField’s Shapefile (.ZIP) → GeoJSON tool. Zip the .shp, .shx, .dbf (and .prj if available), drop the ZIP on the page, preview attributes, then export clean GeoJSON. Below you’ll find precise steps, CRS tips, examples from farms and worksites, and QA checks so your geometry and properties arrive intact. This approach is quick, reliable, and ideal for Leaflet or Mapbox when you don’t want to open a desktop GIS.

Diagram showing SHP, DBF, SHX, PRJ zipped and converted to one GeoJSON file

Shapefile vs GeoJSON: What changes and what stays

  • A Shapefile is actually several files working together: .shp (geometry), .dbf (attributes), .shx (index), plus optional .prj (coordinate reference system).
  • GeoJSON is a single text-based file that stores geometry and properties in one place. It’s ideal for web maps (Leaflet, Mapbox GL) and APIs.
  • Your goal in conversion is to preserve geometry integrity and attribute fields while landing in a web-friendly coordinate system, typically WGS 84 (EPSG:4326) with coordinates as longitude, latitude.

Fast method: Convert Shapefile to GeoJSON in your browser (without QGIS)

  1. Zip your files
    Include at minimum: .shp + .shx + .dbf. Add .prj if available to define the source CRS.

  2. Open the tool
    Go to Shapefile (.ZIP) → GeoJSON: https://gpsfield.com/tools/shapefile-geojson.

  3. Load the ZIP
    Use Choose ZIP or drag the ZIP onto Drop a shapefile ZIP here.

  4. Preview
    Click Preview. Confirm the layer appears and scan the attribute fields you expect (e.g., field_id, crop, width_m).

  5. Convert
    Click Convert to GeoJSON to download a .geojson ready for Leaflet, Mapbox GL, or other web frameworks.

Tip: Immediately open your result in the GeoJSON Spatial Viewer (https://gpsfield.com/tools/geojson-viewer) to double-check geometry types, bounding box, and attributes.

Screenshot of the Shapefile (.ZIP) → GeoJSON tool on GpsField

Why it’s field-safe: conversion runs in your browser

The tool unpacks and converts shapefile archives directly inside your browser. Your data is processed in the page rather than uploaded to a server.

Attributes: .dbf fields are preserved as GeoJSON properties

The converter preserves attribute columns from the .dbf file as properties on each GeoJSON feature. That lets you keep IDs, crop types, widths, zoning, and other fields your downstream map or code depends on. Note that shapefile field naming and length limits still apply at source.

Worked examples from the field

  • Agriculture: A co-op agronomist converts a 125-field boundaries layer to GeoJSON for a Leaflet crop-scouting map. After conversion, they confirm that field_id and crop properties are present so scouts can filter soy vs. corn in the browser.
  • Survey/engineering: A utilities corridors shapefile becomes GeoJSON for a site coordination viewer. LINESTRING geometries and a width_m attribute survive conversion, so trenching crews see the correct buffered overlay.
  • Real estate/land: A broker turns county parcel shapefiles into GeoJSON for a property marketing page. Because attributes came through, they filter by zoning in JavaScript and color by assessed value.

Example numbers: A 540-hectare block stays MultiPolygon, with attributes intact

Suppose a farm boundary is a single MultiPolygon with owner="K. Singh" and area_ha=540.2 in the .dbf. After conversion, the GeoJSON feature still has "type":"MultiPolygon" and "properties":{"owner":"K. Singh","area_ha":540.2}.
Area cross-check: 540.2 hectares × 2.47105381 = 1,334.86 acres (approx.). That confirms your attribute values align with expected units.

Tip: Visualize to spot slivers or holes

Open the output in GeoJSON Spatial Viewer (https://gpsfield.com/tools/geojson-viewer). Toggle feature outlines and zoom edges to find slivers, gaps, or unintended holes that might have come from the source data.

Engineer using converted GeoJSON utility corridors on a tablet at a job site

CRS and projection: Avoid the most common pitfall

  • If your .prj is missing, the source coordinate reference system (CRS) is unknown, and reprojecting reliably becomes guesswork. This is a common cause of layers appearing in the wrong place.
  • Best practice: include the .prj and/or reproject your layer to WGS 84 (EPSG:4326) before web deployment, since most web frameworks expect longitude/latitude degrees.
  • Not sure what your CRS should be? Use EPSG / CRS Lookup (https://gpsfield.com/tools/epsg-lookup) to confirm codes and projection details.

If you must reproject first

  • QGIS: Right-click layer → Export → Save Features As… → Format: GeoJSON → CRS: EPSG:4326.
  • GDAL/OGR: ogr2ogr -f GeoJSON out.geojson input.shp -t_srs EPSG:4326

Validation: check the numbers look like lon/lat

Open your GeoJSON in GeoJSON Spatial Viewer (https://gpsfield.com/tools/geojson-viewer). Coordinates should look like longitude, latitude pairs (e.g., -97.45, 36.12). If you see large Easting/Northing values (e.g., 380000, 4020000), the data is still in a projected CRS and needs reprojection.

How to handle large or complex shapefiles

  • Simplify geometry (topology-aware) in a desktop GIS for heavy layers before converting, especially if the map must load quickly on mobile devices.
  • Split by attribute (county, tile, management zone) and load only what users need. Convert each subset to separate GeoJSON files.
  • Consider compressed topology for shared boundaries. Convert to TopoJSON using TopoJSON ↔ GeoJSON (https://gpsfield.com/tools/topojson-converter) to reduce file size while keeping boundary relationships.

Quality assurance after conversion

  • Load the result in GeoJSON Spatial Viewer (https://gpsfield.com/tools/geojson-viewer). Confirm geometry types (Polygon vs MultiPolygon vs LineString), bounding box, and critical properties.
  • Spot-check attribute encoding. Names with accents should read correctly in UTF-8. If you see garbled text, re-export from your desktop GIS ensuring UTF-8 encoding for GeoJSON.
  • Normalize geometry types if required. Some downstream apps expect all Polygons or all MultiPolygons. Convert or standardize types during export.

Command line and desktop alternatives (when needed)

  • QGIS: Right-click layer → Export → Save Features As… → Format: GeoJSON → set CRS.
  • GDAL/OGR: ogr2ogr -f GeoJSON out.geojson input.shp -t_srs EPSG:4326
  • Python (GeoPandas):
    gpd.read_file('input.shp').to_crs(4326).to_file('out.geojson', driver='GeoJSON')

When to use these

Use desktop or command line when you need batch processing across many files, heavy reprojections between national datums, schema edits (renaming or recalculating fields), or scripted pipelines in CI. If you need the reverse direction (GeoJSON to Shapefile), GDAL/OGR and GeoPandas also write ESRI Shapefile.

Troubleshooting: fixes for common errors

  • Missing .prj: Add the correct .prj or reproject in QGIS, then re-zip and convert. Without CRS info, coordinates may land in the wrong place.
  • Invalid geometry: In QGIS, run Fix Geometries on the source layer before conversion to resolve self-intersections or bowties.
  • Attribute truncation: Shapefile limits field names to 10 characters and fixed widths. If you see truncated names or values, rename fields and adjust widths in your GIS, then export again.
  • Multipart surprises: MultiPolygon output is normal when boundaries were dissolved or features contain islands/holes. Ensure your web app supports MultiPolygon or standardize types as needed.

Use your new GeoJSON right away

  • Leaflet:
    L.geoJSON(data).addTo(map);
    Style or filter by properties (e.g., crop, zoning) for fast theming in the field.
  • Mapbox GL JS:
    map.addSource('parcels', { type: 'geojson', data: 'out.geojson' });
    map.addLayer({ id:'parcels-fill', type:'fill', source:'parcels', paint:{ 'fill-color':['match',['get','zoning'],'Ag','#7fb80e','#3388ff'] }});
  • Stakeholders on Google Earth? Convert your GeoJSON to KML with GeoJSON → KML (https://gpsfield.com/tools/geojson-kml).

Step-by-step recap for pros in a hurry

  • Zip .shp + .shx + .dbf (+ .prj), open Shapefile (.ZIP) → GeoJSON, Preview, Convert, then validate in GeoJSON Spatial Viewer.

Try it now: Convert Shapefile to GeoJSON

Frequently asked questions

What files do I need to convert a shapefile to GeoJSON?

Include at least .shp (geometry), .shx (index), and .dbf (attributes) in one ZIP. If you have it, add the .prj file so the tool knows the source CRS. Then load that ZIP into Shapefile (.ZIP) → GeoJSON (https://gpsfield.com/tools/shapefile-geojson) and convert.

Will attributes and field names be preserved when I convert SHP to GeoJSON?

Yes—fields from the .dbf are preserved as properties in GeoJSON features. Keep in mind shapefile limits (e.g., 10-character field names and fixed widths). If labels look truncated, rename fields in your GIS and export again.

Do I need to reproject to WGS 84 (EPSG:4326) before converting for web maps?

Most web maps (Leaflet, Mapbox GL) expect longitude/latitude in WGS 84. If your shapefile isn’t already in EPSG:4326, reproject first in QGIS or GDAL, or ensure a correct .prj is present and convert, then verify coordinates look like lon/lat. Use EPSG / CRS Lookup (https://gpsfield.com/tools/epsg-lookup) if you’re unsure of the right code.

How can I convert JSON to Shapefile if I need to go the other way?

On the command line with GDAL: ogr2ogr -f "ESRI Shapefile" out.shp input.geojson. In Python, GeoPandas can write to ESRI Shapefile as well. If you’re building a two-way workflow, keep field names within shapefile limits to avoid truncation.


Convert, validate, and deploy in minutes. Start with Shapefile (.ZIP) → GeoJSON (https://gpsfield.com/tools/shapefile-geojson).

Tags & Topics

GisGeojsonShapefileConversionMapping