{"canonical_url":"https://engineer.company/glossary/geojson/","content_markdown":"# GeoJSON\n\n## What it is\n\nGeoJSON is an open format for exchanging map features, the points, lines and\nareas of a map together with the facts attached to them, as one plain JSON\ndocument. The IETF standardised it as RFC 7946 in August 2016, replacing the\ncommunity specification first published in 2008. A GeoJSON text travels with the\nmedia type `application/geo+json` and is usually saved with the .geojson\nextension, although plain .json is registered as well.\n\nThe format has three kinds of object, and each one says which kind it is in a\n\"type\" member.\n\n- **Geometry** is a shape. There are seven types: Point, MultiPoint, LineString,\n  MultiLineString, Polygon, MultiPolygon and GeometryCollection. They are the\n  shapes of the Simple Features model from the Open Geospatial Consortium (OGC),\n  the same ones that the WKT and WKB encodings carry in text and binary.\n- **Feature** is one thing on the map: a geometry, a \"properties\" object holding\n  its attributes, and an optional \"id\". The geometry may be null for a feature\n  whose location is unknown.\n- **FeatureCollection** holds a list of features in a \"features\" member. It is\n  what most files and API responses contain.\n\nA single feature for a smart meter looks like this:\n\n```json\n{\n    \"type\": \"Feature\",\n    \"id\": \"meter-0417\",\n    \"geometry\": {\n        \"type\": \"Point\",\n        \"coordinates\": [12.5683, 55.6761]\n    },\n    \"properties\": {\n        \"name\": \"Meter 417\",\n        \"installed\": \"2023-04-12\"\n    }\n}\n```\n\nEach position is an array of numbers: longitude first, then latitude, then an\noptional altitude in metres. The specification says the first two come\n\"precisely in that order\", so the point above sits in central Copenhagen, 12.57\ndegrees east and 55.68 degrees north. Every coordinate uses one reference\nsystem, WGS 84 longitude and latitude in decimal degrees, which the OGC\nidentifies as CRS84. The 2008 version let a file name another system in a \"crs\"\nmember. RFC 7946 removed that member because mixed reference systems had caused\ninteroperability problems, and it allows another system only where every party\nhas agreed on it in advance.\n\nPolygons carry rules of their own. Each ring is closed, with at least four\npositions and the last one repeating the first. The first ring is the outer\nboundary and any later rings are holes. RFC 7946 adds a right-hand rule, with\nouter rings running counterclockwise and holes clockwise, but because the 2008\nversion said nothing about winding, parsers are told to accept polygons that\nbreak it.\n\n## Why it matters\n\nAnything that reads JSON can read GeoJSON. A browser parses it with no plugin, a\nweb-mapping library draws it directly and a document database stores it as it\nis. RFC 7946 notes that it \"is widely used in JavaScript web-mapping libraries,\nJSON-based document databases, and web APIs\". That reach makes it the usual\nformat whenever map data leaves a desktop GIS for a web page or an API.\n\nStandards build on it as well. OGC API – Features, the OGC standard for serving\ngeographic features over HTTP, recommends GeoJSON wherever the data can be\nrepresented in it. A server that offers GeoJSON returns a FeatureCollection for\na list of features and a single Feature for one, both as `application/geo+json`,\nand its default reference system is the same WGS 84 longitude and latitude that\nGeoJSON fixes.\n\nThe same design choices set its limits.\n\n- **One reference system.** Data held in a national grid has to be transformed\n  into longitude and latitude before it is written, and transformed back by any\n  consumer that measures in metres.\n- **Simple shapes only.** The geometry types cover points, straight-sided lines\n  and polygons. Curves, solids such as 3D city models and coordinates outside\n  WGS 84 fall outside the format, and OGC API – Features gives exactly those\n  cases as its examples of data that GeoJSON cannot carry.\n- **Size.** Every coordinate is written out as decimal digits, and a\n  FeatureCollection is a single JSON value, which an ordinary JSON parser reads\n  to the last byte before handing back any feature in it. RFC 8142 defines\n  GeoJSON Text Sequences, media type `application/geo+json-seq`, with one\n  GeoJSON text per record, so that arbitrarily large datasets can be read\n  incrementally.\n- **No shared edges.** Two neighbouring polygons each store their common border\n  in full, so the border is written twice, and an edit to one copy can open a\n  gap or an overlap.\n\nRFC 7946 is also plain about what the format leaves to others. GeoJSON provides\nno privacy or integrity protection of its own, so data in transit relies on TLS.\nThe security section warns that publishing the locations of sensitive people,\nanimals, habitats or facilities can expose them to tracking or harm, and that\nblurring positions in an anonymised dataset is unlikely to defeat a determined\nattack.\n\n## What it looks like in practice\n\nGeoJSON was one of the formats that GDAL/OGR moved data between, alongside\nshapefiles, GeoTIFF, KML and vector tiles, on\n[more than thirty GIS projects that were built, deployed and supported in production](/portfolio/led-30-gis-projects-from-build-to-support/).\nPostgreSQL with PostGIS held the spatial data underneath, QGIS and JOSM served\nfor the data work itself, and the browser maps on top used Mapbox GL and\nLeaflet.\n\nA reference system has to be settled before any of that. In\n[a migration from MSSQL to PostgreSQL with the PostGIS extension](/portfolio/improved-gis-map-performance-10x-on-postgresql/),\nover 50 million spatial records went through ETL pipelines whose transformation\nsteps brought them to the SRID standard EPSG:4326. That code names the same WGS\n84 datum in degrees that GeoJSON fixes, and the PostGIS manual states that the\noutput of its ST_AsGeoJSON function conforms to RFC 7946 for geometry in\nEPSG:4326, with no transform needed.\n\n## Where it goes wrong\n\n**Points land in the wrong sea.** A layer of Danish addresses appears in the\nmiddle of the Arabian Sea, and every range check still passes because both\nnumbers are valid degrees. Latitude and longitude were swapped on the way in.\nEPSG:4326 formally lists latitude before longitude, many data sources follow it,\nand GeoJSON wants longitude first. Build each position from named fields rather\nthan from column order, and keep a test feature at a known address so that a\nswap fails a test instead of a map review.\n\n**Coordinates arrive in metres.** A layer is missing from the map or rejected by\nthe client, and the file holds coordinates in the hundreds of thousands where\ndegrees belong. The geometry was stored in a projected national grid and\nexported as it was. Transform it to longitude and latitude first, with\n`ST_Transform(geom, 4326)` in PostGIS. Left untransformed, ST_AsGeoJSON attaches\na \"crs\" member by default, the member RFC 7946 removed.\n\n**Polygons draw inside out in one client.** A service area fills the whole map\nexcept its own shape, while other tools draw the same file correctly. That\nclient relies on the direction of each ring to tell inside from outside, and the\nrings run the other way, which the 2008 version allowed. The PostGIS manual\nnotes that some clients require the right-hand rule, so apply it before export\nwith `ST_ForcePolygonCCW(geom)`, and test the output in every client that\nconsumes it.\n\n**Files carry more digits than the map needs.** A layer of detailed polygons\ntakes seconds to download on a phone, and its coordinates run to nine or more\ndecimal places. ST_AsGeoJSON writes up to nine decimal places by default, and\nRFC 7946 notes that going from six to fifteen can nearly double a text's size,\nwhile six already resolves about 10 centimetres. Pass a smaller\n`maxdecimaldigits`, and reduce precision with `ST_ReducePrecision` first,\nbecause the PostGIS manual warns that trimming digits on output alone can make a\ngeometry invalid.\n\n**Internal columns ship inside properties.** A public endpoint returns owner\nnames, cost figures or notes that were meant to stay in the database.\nST_AsGeoJSON, given a whole row, puts every column except the geometry into\n\"properties\". Select only the columns meant for publication in a subquery, and,\non PostGIS 3.5 or later, name the key column so that it becomes the feature's\n\"id\":\n\n```sql\nSELECT json_build_object(\n  'type', 'FeatureCollection',\n  'features', json_agg(ST_AsGeoJSON(m.*, id_column =\u003e 'id')::json)\n)\nFROM (SELECT id, name, geom FROM meters) AS m;\n```\n\n## Further reading\n\n- [RFC 7946: The GeoJSON Format](https://www.rfc-editor.org/rfc/rfc7946) — the\n  IETF standard, with the object types, coordinate order, winding rule,\n  precision advice and security considerations.\n- [RFC 8142: GeoJSON Text Sequences](https://www.rfc-editor.org/rfc/rfc8142) —\n  the companion format that splits a large dataset into one GeoJSON text per\n  record.\n- [ST_AsGeoJSON](https://postgis.net/docs/ST_AsGeoJSON.html) — the PostGIS\n  manual page for exporting geometry and whole rows as GeoJSON, with its\n  precision and option flags.\n- [EPSG:4326 WGS 84](https://epsg.org/crs_4326/WGS-84.html) — the registry entry\n  whose axis order puts latitude first, the opposite of GeoJSON.\n- [OGC API – Features – Part 1: Core](https://docs.ogc.org/is/17-069r4/17-069r4.html)\n  — the OGC standard that recommends GeoJSON for serving features over HTTP.\n\n\u003chttps://engineer.company/glossary/geojson/\u003e\n","date_modified":"2026-10-20T21:59:50Z","description":"How GeoJSON stores map features for browsers and web APIs, why its coordinates run longitude first, and the mistakes that misplace or bloat data.","formats":{"gemtext":"https://engineer.company/glossary/geojson/index.gmi","gopher":"https://engineer.company/glossary/geojson/gophermap","html":"https://engineer.company/glossary/geojson/","json":"https://engineer.company/glossary/geojson/index.json","markdown":"https://engineer.company/glossary/geojson/index.md","pdf":"https://engineer.company/glossary/geojson/index.pdf"},"kind":"page","language":"en","title":"What is GeoJSON?","url":"https://engineer.company/glossary/geojson/","version":1}