I'm manipulating GeoJSON objects in a web application. Leaflet accepts the POJOs with the correct GeoJSON format.

But I'd like to use a specific library that creates those POJOs, taking care of the format specification. A library that provides a solid Object Oriented interface.

I receive my data from a REST API and I need to manually create the GeoJSON objects. I think it is not robust to just use simple JS objects. So, I'd love to have a library that supports that part of the work.

I can't specify more about the data format. The only thing I can say is that I get all that's necessary to create GeoJSON objects. The question aims to find a general purpose library. For example in Python, I'd use something like this: https://github.com/frewsxcv/python-geojson

But I cannot find a similar thing in Javascript. Do you know if such a thing exists?

  • Can you clarify the format in which you are receiving the data from the REST API (also what sort of server are you calling)? Sep 7, 2016 at 8:27
  • I've updated the question to clarify that I'm looking for a general purpose library. The format of my data is unimportant at this point.
    – Akhorus
    Sep 7, 2016 at 20:55
  • Would this library solve your problem? Sep 7, 2016 at 21:12
  • 2
    Turf.js has constructors as well as Spatial operations.
    – klewis
    Sep 7, 2016 at 22:00
  • The reason I ask about the format of the incoming data and its source is that the former may influence the choice of library and the latter might just provide a solution, for instance many geo-data servers will give you GeoJson or if you have JSON that needs a little wrangling to make it geojson, then there is a very simple and robust tool you can use. Without telling us more about the incoming data and its source all suggestions will be a shot in the dark and possibly overkill for your needs. Sep 8, 2016 at 8:22

1 Answer 1


> I think it is not robust to just use simple JS objects.

Json (and geojson) is valid javascript object notation, so it seems circular to say it is not robust to use simple Js objects. Or said another way, Json == simple Js objects.

I am not trying to be snarky- just saying: just build javascript data structures, then serialize them to geojson strings as necessary.

That said, both the Turf and geojson_lite libraries linked above look pretty great. (bookmarking both of those ones myself)!

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.