How to Convert Shapefile to GeoJSON

Published · Last updated

Move GIS boundary and operational datasets into GeoJSON workflows for web maps, logistics systems and software platforms.

Try it now: GeoJSON, TopoJSON, KML and Shapefile converter

Before you start

A Shapefile is a vector data format commonly used in GIS applications such as QGIS and ArcGIS. It can contain points, lines and polygons together with attribute data. GeoJSON is a JSON-based geospatial format that is widely supported by web mapping libraries and modern applications.

Converting a Shapefile to GeoJSON makes it easier to use geographic data in web applications, APIs, logistics systems and other software that supports GeoJSON. For example, a GIS team might prepare service-area boundaries or distribution regions for a web-based operations tool. The conversion changes the data representation but should preserve the underlying geographic features and their attributes.

Before converting, make sure you have the complete Shapefile dataset. A Shapefile normally consists of several files that work together.

Shapefile components

A Shapefile is not a single file. It consists of several files sharing the same filename but using different extensions.

  • .shp: Contains the actual geometric features.
  • .shx: Contains the geometry index.
  • .dbf: Contains attribute data associated with each feature.
  • .prj: Describes the coordinate reference system.
  • .cpg: Optionally describes the character encoding of the attribute data.

The SHP, SHX and DBF files are the essential components. Keeping the associated PRJ file is important because it helps identify the coordinate reference system of the source data.

Shapefiles are often distributed as ZIP archives containing these files. Keep the original filenames consistent when preparing the dataset.

Worked example

Imagine you have a Shapefile containing administrative boundaries. Each feature represents a geographic area and has attributes such as its name and administrative code.

A simplified representation of one resulting GeoJSON feature could look like this:

{
  "type": "Feature",
  "properties": {
    "name": "Central District",
    "code": "CD001"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [12.50, 55.70],
        [12.60, 55.70],
        [12.60, 55.80],
        [12.50, 55.80],
        [12.50, 55.70]
      ]
    ]
  }
}

The geometry is represented as a Polygon, while the original attribute information is stored in the properties object. A complete conversion containing several areas will normally use a FeatureCollection.

Step-by-step conversion

  1. Prepare the complete Shapefile dataset, including its associated files.
  2. Open the GeoJSON, TopoJSON, KML and Shapefile converter.
  3. Set From to Shapefile and To to GeoJSON.
  4. Provide the Shapefile data using the input method supported by the converter.
  5. Press Convert.
  6. Review the generated GeoJSON and download the result.
  7. Open the output in a GIS application or use the GeoJSON viewer to inspect the geographic features.

Coordinate systems

One of the most important things to check when converting a Shapefile is its coordinate reference system (CRS).

Shapefiles can use projected coordinate systems such as UTM, or geographic coordinate systems such as WGS84. GeoJSON uses WGS84 longitude and latitude coordinates.

  • WGS84: Geographic coordinates expressed as longitude and latitude.
  • UTM: Projected coordinates expressed as easting and northing, usually in metres.
  • Other projected systems: May require reprojection before the data can be used as standard GeoJSON.

Do not assume that coordinates are WGS84 simply because the file has been converted to GeoJSON. Verify that the conversion handles the source CRS correctly and that the resulting coordinates are expressed in longitude and latitude.

Common errors

  • Missing Shapefile components. The SHP, SHX and DBF files must belong to the same dataset. Missing components can prevent the data from being read correctly.
  • Incorrect coordinate reference system. Projected coordinates must be transformed to WGS84 for standard GeoJSON output.
  • Missing attribute data. Check that the DBF file is included and that the expected attributes appear in the resulting properties objects.
  • Character encoding problems. Incorrect encoding can cause names containing special characters to display incorrectly.
  • Invalid resulting GeoJSON. Run the output through the GeoJSON validator before using it in another application.

Once converted, GeoJSON can also be converted to KML or TopoJSON using the same format converter. The API supports documented document conversions for software workflows; review the API overview and API reference for its accepted Shapefile input and output formats.

If the output does not parse or display as expected, follow the GeoJSON validation guide and inspect the features in the map viewer.

Tools used in this guide

Related guides

Browse all technical guides