How can I use JavaScript to load a JSON file from my desktop? Alternatively, for a more direct approach:

16 Replies, 804 Views

Bro, browsers block javascript load json file from desktop for security reasons. You gotta either:

- Drag & drop the file into the browser (kinda hacky but works for quick tests)
- Use Node.js if you're okay with running it outside the browser (`fs.readFileSync('path/to/file.json')`)
- Or like others said, spin up a local server.

Also, check if your JSON is valid—sometimes errors come from malformed files.

Messages In This Thread



Users browsing this thread: 1 Guest(s)