GML to GeoJSON Converter
The most common reason you'd want this: you've downloaded a dataset from an INSPIRE portal and need to render it in Mapbox / Leaflet / d3.
Common issues converting GML to GeoJSON
- Both gml:coordinates (GML 2) and gml:posList (GML 3) syntaxes are parsed. Mixed documents are handled.
- Application-schema-specific elements (e.g., INSPIRE thematic attributes) survive as flat property keys but lose their XML nesting — if your downstream pipeline needs the hierarchy, post-process before converting.
- GML's srsName per geometry is read; the output is always WGS 84. If the source uses a projected CRS (common with national mapping agencies), reproject in the request.
- XXE attacks: any <!DOCTYPE> blocks are stripped before parsing. Safe for untrusted inputs.
Frequently asked questions
Does the converter handle GML 3 posList?
Yes. Both <gml:coordinates>x,y x,y</gml:coordinates> and <gml:posList>x y x y</gml:posList> patterns are parsed, with sensible 2D defaults when dimension is ambiguous.
What about MultiSurface / MultiCurve in GML 3?
Currently only the base geometries (Point, LineString, Polygon) are extracted. MultiSurface decomposes to its first member polygon. For full GML 3 multi-geometry support, post-process.
Will it work on a WFS getFeature response?
Yes — WFS GetFeature returns <wfs:FeatureCollection> wrapping <gml:featureMember> entries, which is what our parser walks. Different prefix namespaces are matched permissively.
Is it safe to point this at user-uploaded GML?
Yes — DOCTYPE blocks are stripped pre-parse to neutralise XXE, and regex-based extraction means no XML entity expansion can run.