I have been given a set of folders with a .html file, that was exported from QGIS plug-in "qgis2web". Normally you can just click on the .html file and it will open a local version of a QGIS authored website. I don't know the origin of these folders and I don't have access to the original data. The spatial layer is stored in a 'data' folder is a JScript Script File (.js). Is it possible to pluck these files out and view them in another program or ideally convert them to shape files (.shp)?

  • The JS file may really be GeoJSON, Open one up and copy/paste contents into geojsonlint.com to check. if so their are several on-line converters for GeoJSON to ShapeFile, or CSV. QGIS is free and can also convert it in a desktop setting. Commented Dec 17, 2017 at 3:54

1 Answer 1


qgis2web exports JSONP, not JSON (https://en.wikipedia.org/wiki/JSONP). JSONP is an encapsulation of JSON in Javascript which allows it to be requested cross-domain without CORS headers or proxy. JSONP cannot be loaded into a GIS (as far as I am aware) in order to convert it to a shapefile.

However, it's very simple to convert the JSONP files to JSON. Open the JSONP file in a text editor, and delete everything from the beginning of the file up to, but excluding, the opening curly brace: {. Then save your file, changing the file extension from .js to .json.

The resulting file should be valid JSON. You should therefore be able to open it in GISes which support JSON, such as QGIS, or use any conversion software which supports JSON. You can then convert it to a shapefile.

  • The first line... is the whole thing. I opened my file cenusblocks_0.js in Notepad++ and there is 1 line of length 52 million. It takes 10+ minutes to open and I can't edit anything. It zips down to 4MB, not sure if I can upload it here. Commented Dec 20, 2017 at 21:20
  • I was able to copy and paste the beginning of the file, I had to erase the coords that occurred within the following; see below: Commented Dec 20, 2017 at 21:31
  • var json_CensusBlocks_0 = {"type":"FeatureCollection","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:OGC:1.3:CRS84"}},"features":[{"type":"Feature","properties":{"GEOID10":"060030100002006","UR10":"R"},"geometry":{"type":"Polygon","coordinates":[[[-119.7928,38.8341]]}},{"type":"Feature","properties":{"GEOID10":"060030100001214","UR10":"R"},"geometry":{"type":"Polygon","coordinates":[[[-119.7275,38.806]]}},{"type":"Feature","properties":{"GEOID10":"060030100001081","UR10":"R"},"geometry":{"type":"Polygon","coordinates":[[[-119.7903,38.7047],[-119.7902,38.7044] Commented Dec 20, 2017 at 21:33
  • Apologies. I've amended my answer above. Delete up to the first {, and change the file extension from .js to .json. Commented Dec 20, 2017 at 22:30

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.