Serve a json file with CORS and Options with a simple binary
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Serve a json file via HTTP with CORS and content-type headers in a route.

# execute server
❯ servejson -file fixtures/test.json -route api/file.json -port 8080
2018/03/12 20:38:44 Serving fixtures/test.json at /api/file.json in port 8080

# execute client
❯ http localhost:8080/api/file.json | jq .
  "foo": "bar"

This is useful to test HTTP requests from a browser (uses OPTIONS, needs CORS) to a real server.

Install or update

go get -u

Or download the binaries for MacOS or Linux from the latest release page.


I wanted to serve a json easily and quickly, not to download the whole internet or configure something complex.


  • check is a valid json file
  • enable/disable CORS flag