How to Open a GeoJSON File (and What It Is)
A .geojson file holds map data: points, lines and shapes, each with a set of attributes. City open-data portals, mapping APIs and GIS programs all export it because it is plain text that any programming language can read.
You can open it in a text editor, but you will just see coordinates. To see the data as a map you need a viewer. This guide explains how the format works and shows several ways to open it, from a browser tab to Python.
What is a GeoJSON file? #
GeoJSON is a JSON format for geographic features, standardized in 2016 as RFC 7946. A typical file is a FeatureCollection, a list of features. Each Feature has a geometry (where it is) and properties (what it is):
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [-122.4194, 37.7749] },
"properties": { "name": "San Francisco", "population": 808437 }
},
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[-122.4194, 37.7749],
[-118.2437, 34.0522]
]
},
"properties": { "name": "SF to LA" }
}
]
}
The geometry types are Point, LineString and Polygon, their multi-part versions MultiPoint, MultiLineString and MultiPolygon, and GeometryCollection.
Two rules matter in practice:
- Coordinates are longitude first, then latitude.
[-122.4194, 37.7749]is San Francisco. This is the opposite of how most people write coordinates, and the most common source of broken files. - Coordinates are in WGS 84 degrees, the same system GPS uses. Older files written before RFC 7946 sometimes use a
crsmember and projected coordinates in meters instead.
The file extension is usually .geojson, sometimes .json.
Option 1: view it on a map in your browser #
The GeoJSON Viewer draws the file on an interactive map. The file is parsed in your browser, so the data is not uploaded.
- Open the GeoJSON Viewer and drop your
.geojsonor.jsonfile on it. - The map zooms to your features. Pan and zoom to explore.
- Click any point, line or polygon to see its properties.
- Export the data as GeoJSON again when you are done.
It accepts a FeatureCollection, a single Feature, a bare geometry, and newline-delimited GeoJSON sequences. If some entries are invalid, it skips them and tells you which ones, instead of refusing the whole file.
Option 2: a text editor, to read the raw data #
Because GeoJSON is JSON, any text editor opens it. VS Code, Sublime Text or Notepad++ can format and fold it, which is handy for checking property names or finding one feature. For a quick summary on the command line, jq works well:
jq '.features | length' places.geojson # how many features
jq '.features[0].properties' places.geojson # attributes of the first one
Option 3: QGIS, for full GIS work #
QGIS is the free, open-source desktop GIS for Windows, macOS and Linux. Drag the .geojson file into the window, or use Layer > Add Layer > Add Vector Layer. Open the attribute table to see the properties as rows. QGIS can also style the layer, combine it with other data, reproject it and save it to other formats such as GeoPackage or shapefile.
Option 4: Python with GeoPandas #
GeoPandas reads GeoJSON into a table with a geometry column:
pip install geopandas
import geopandas as gpd
gdf = gpd.read_file("places.geojson")
print(gdf.head()) # properties plus a geometry column
print(gdf.crs) # EPSG:4326 for standard GeoJSON
# Just the attributes, as a CSV
gdf.drop(columns="geometry").to_csv("places.csv", index=False)
If you prefer SQL, DuckDB's spatial extension reads the same file:
INSTALL spatial;
LOAD spatial;
SELECT name, ST_GeometryType(geom) AS type FROM ST_Read('places.geojson');
Option 5: GitHub and other quick previews #
If the file is in a GitHub repository, GitHub renders .geojson files as a map when you open them. The free web editor geojson.io also opens and edits small files.
When the map is empty or in the wrong place #
-
Everything sits in the ocean or the wrong country. Longitude and latitude are swapped. Paris is
[2.35, 48.86]; written as[48.86, 2.35]it lands in the Indian Ocean off Somalia. For places in the Americas the swapped latitude is outside -90 to 90, so viewers may drop the features entirely. The fix is to swap the two numbers in every coordinate pair, which QGIS and GeoPandas can do for a whole layer. -
Nothing appears, and the coordinates are large numbers like
-13627361. The file uses a projected system in meters, such as Web Mercator, not degrees. Reproject it to WGS 84. In GeoPandas, assuming the source is Web Mercator (EPSG:3857):gdf = gpd.read_file("projected.geojson") gdf.set_crs(3857, allow_override=True).to_crs(4326).to_file("fixed.geojson", driver="GeoJSON") -
"Invalid JSON". The file is cut off or has a stray character. Text editors with JSON support point to the exact line.
-
The file is huge and slow. GeoJSON repeats property names for every feature and stores coordinates as text, so files get large quickly. Simplify geometries in QGIS or Mapshaper, or store large datasets as GeoPackage or GeoParquet and export GeoJSON only for the web.
Converting other map formats to GeoJSON #
GeoJSON is the common format most web maps expect, so it is often the target of a conversion:
- KML (Google Earth): the KML to GeoJSON converter converts Point, LineString and Polygon placemarks, with names, descriptions and simple ExtendedData values, and previews the result on a map. To go back to Google Earth, use the GeoJSON to KML converter.
- Shapefiles: the Shapefile Viewer opens a
.zipcontaining the.shp,.dbf,.shxand.prjfiles and exports GeoJSON. The Shapefile to GeoJSON converter does the conversion directly. - GPX (GPS tracks): use the GPX to GeoJSON converter.
FAQ #
What program opens a GeoJSON file? #
Any text editor shows the raw JSON. To see it on a map, use the GeoJSON Viewer in your browser, QGIS on the desktop, or GeoPandas in Python.
Is GeoJSON the same as JSON? #
GeoJSON is JSON with a fixed structure for geographic data. Every GeoJSON file is valid JSON, but not every JSON file is GeoJSON.
Can I open a GeoJSON file in Excel? #
Not as a map. Excel can import JSON with Power Query, but the geometry ends up as nested lists. To get the attributes as a table, export them to CSV with GeoPandas as shown above, or with QGIS (Export > Save Features As > CSV).
What is the difference between GeoJSON and a shapefile? #
A shapefile is a set of several files (.shp, .dbf, .shx, .prj) in a binary format from Esri. GeoJSON is a single text file. Shapefiles are common in desktop GIS; GeoJSON is the default for web maps. The Shapefile Viewer opens a shapefile and exports it as GeoJSON.
Why does GeoJSON use longitude before latitude? #
It follows the x, y order of math and most GIS software, where x is east-west (longitude) and y is north-south (latitude). RFC 7946 makes this order mandatory.
Try the tools from this post
Free and private: your files stay in your browser.