How can GeoJSON data to TopoJSON be converted?

TopoJSON files are often smaller than GeoJSON and the conversion allows you to incrementally simplify a dataset, if you wish.

  • Step 3: Convert the data: topojson -o output_file.json input_file.json not working!!!!!!!!!!!!
    – user21773
    Sep 6, 2013 at 17:00
  • 1
    topojson -o output_file.json input_file.json works for me under 1.1.0 and 1.4.0. Perhaps you can ask a formal question on here with more info on the problem you're having? Cheers!
    – Jeff
    Sep 6, 2013 at 18:09

4 Answers 4


Glad you asked, oh handsome OP.

Install topojson

From the command line (Mac OSX 10.8, assumes homebrew installed):

brew install node.js
npm install -g topojson

Convert The Data

topojson -o output.json input.json
  • 1
    OP is handsome, but needs to update his answer. Feb 18, 2019 at 8:42

The function to create a topojson from a geojson in topojson has been moved to geo2topo

npm install topojson-server -g
geo2topo input.geojson > output.topojson
  • For me this does not work. I am getting a not recognized error when trying to run geo2topo after running npm install topojson-server
    – JoeBe
    Jan 31, 2020 at 2:34
  • Updated the answer to include the global flag -g try it now @JoeBe
    – ow3n
    Jan 31, 2020 at 16:35
  • thanks. This worked perfectly. It would be great if you could tell me what the difference is here? Why do I need a global flag for this whereas for other libraries I installed until now this was not necessary? What happens behind the hood?
    – JoeBe
    Feb 10, 2020 at 1:51
  • 1
    Install globally if you are using a package as a command line tool and locally if it only needs to be accessible from scripts in an app stackoverflow.com/a/8951576/441878
    – ow3n
    Feb 10, 2020 at 11:25

I ported the TopoJSON code from JavaScript to Python, following the exact same format Mike uses in his library (along with his +300 tests).

If you feel better with Python, just install the library by running:

pip install pytopojson

And then run:

python geo2topo.py geojson_file

You can also use a quantization parameter. Just use the -h argument to see how it works.

Let me know if this was helpful to you!


I have found pretty good online tool for simplifying geospatial data (including GeoJSON) and export to various formats (including TopoJSON) at https://geoprocessing.online/tool/simplify-polygons/. You can upload the GeoJSON, set simplification level and export to TopoJSON. For more information on data size reduction, see this article: https://kb.geoczech.org/knowledge-base/how-to-reduce-size-of-vector-data/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.