GeoJSON vs TopoJSON
Choose between GeoJSON and TopoJSON for delivery locations, routes, shared boundaries and geographic data exchange.
Try it now: GeoJSON, TopoJSON, KML and Shapefile converter
What is GeoJSON?
GeoJSON is an open standard for representing geographic data using JSON. It is widely used in web mapping, geographic APIs and data exchange between GIS applications.
GeoJSON supports several geometry types, including Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon and GeometryCollection. These geometries can be combined with properties to create geographic features.
A typical GeoJSON dataset contains a FeatureCollection with multiple geographic features.
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "Copenhagen"
},
"geometry": {
"type": "Point",
"coordinates": [12.5683, 55.6761]
}
}
]
}
GeoJSON is easy to read, edit and process because its structure is based on standard JSON objects and arrays. That makes it a practical exchange format for individual delivery locations, GPS-derived line features and applications that consume ordinary GeoJSON objects.
What is TopoJSON?
TopoJSON is an extension of GeoJSON that represents geographic topology. Instead of storing every geometry independently, it stores shared boundaries as reusable arcs.
This is particularly useful when working with administrative boundaries, maps and datasets where adjacent polygons share borders.
A logistics or mapping application displaying many adjacent delivery districts may benefit from representing shared boundaries as topology, provided its map stack supports TopoJSON. For point locations or data exchanged with services that expect GeoJSON, GeoJSON is often the simpler integration format.
For example, a dataset containing several neighboring countries may represent their common borders only once. Each country's geometry references the relevant arcs instead of storing duplicate coordinates.
TopoJSON can also use quantization and coordinate transformations to reduce the amount of data required to represent geographic features.
Key differences
| Characteristic | GeoJSON | TopoJSON |
|---|---|---|
| Data structure | JSON geometry objects | Topological arcs and objects |
| Shared boundaries | Usually stored separately | Can be stored once and reused |
| Readability | Relatively easy to read | More complex structure |
| File size | Can contain duplicated coordinates | Can be smaller for suitable datasets |
| Topology | Does not explicitly encode shared boundaries | Explicitly represents topological relationships |
| Typical use | APIs, web maps and data exchange | Efficient storage and visualization of related geographic features |
The actual file-size difference depends on the dataset. TopoJSON is not guaranteed to be smaller for every type of geographic data.
When to use each format
Use GeoJSON when:
- You need a widely supported format for web mapping.
- You want to inspect or edit geographic data manually.
- You are exchanging data between APIs and GIS applications.
- Your application expects standard GeoJSON objects.
Use TopoJSON when:
- You are working with administrative boundaries or neighboring polygons.
- Shared boundaries should be represented only once.
- You want to reduce data size for suitable geographic datasets.
- Your mapping application supports TopoJSON.
For example, a transport application displaying individual delivery locations will often benefit from GeoJSON. A map displaying hundreds of administrative areas with shared boundaries may benefit from TopoJSON.
Conversion example
GeoJSON and TopoJSON can be converted between each other when the application supports both formats.
- Open the format converter.
- Choose GeoJSON as the source format and TopoJSON as the target format.
- Provide your GeoJSON data.
- Press Convert.
- Download and inspect the resulting TopoJSON.
To convert back, select TopoJSON as the source format and GeoJSON as the target format.
If you are starting with GeoJSON, you can inspect its geometry and structure using the GeoJSON viewer before converting it.
Common misconceptions
- TopoJSON is not simply compressed GeoJSON. It changes how geometry is represented by introducing topology and reusable arcs.
- TopoJSON is not always smaller. The benefits depend on the amount of shared geometry and the characteristics of the dataset.
- Conversion does not automatically improve data quality. Invalid geometries and incorrect source coordinates may still cause problems.
- Topology does not guarantee perfect geometry. The resulting data should still be checked for the requirements of your application.
If you need a format that is easy to exchange between different GIS applications and web services, GeoJSON is often the simplest choice. If shared boundaries and efficient representation are important, TopoJSON is worth considering.
To compare another exchange format, see how to convert GeoJSON to KML. If your source is a traditional GIS dataset, start with Shapefile to GeoJSON conversion.