Sometimes you want visitors to download data as a JSON file directly from your site, without a server round trip. This guide shows how to generate and download a JSON file from a website using simple JavaScript. Copy the code and export any data you like.
1. Using Browser Developer Tools (Best for hidden data)
If you want the data powering their calculator or the list of reviews, follow these steps:
- Open website in Chrome or Firefox.
- Right-click anywhere and select Inspect (or press F12).
- Go to the Network tab.
- Refresh the page (Ctrl + R).
- In the “Filter” box, type Fetch/XHR.
- Look for files that end in .json or have a “Type” of fetch or xhr.
- To Download: Right-click the name of the file and select Open in new tab. Once it opens, right-click the page and choose Save as… to save it as a .json file.
How it works
The script turns your data into a JSON string, wraps it in a downloadable blob, and triggers a download with your chosen file name. Everything happens in the browser, so no backend is needed. The visitor gets a ready to use file instantly.
Tips and customization
- Set a clear file name for the download.
- Format the JSON for readability if humans will open it.
- Build the data from a form or a variable before exporting.
FAQ
Does it work without a server?
Yes. The file is created and downloaded entirely in the browser.
Can I export form data?
Yes. Collect the values into an object, then export it as JSON.
