Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including simple-mock-server with all npm packages installed. Try it out:

var simpleMockServer = require("simple-mock-server")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

simple-mock-server v0.2.1

a static file server and mock json endopint server


static file and JSON endpoint http server

This is a standalone http server that can serve out standard file contents as well as JSON content matching a mock restful endopint.


npm install -g simple-mock-server


The server will serve out files from the directory in which it was started (by typing simpl-mock-server)

If the URI path has no extension, a .json extension will be appended. Any query parameters will be removed as well.

If the method is anything other than GET, the method will be added as a suffix to the file name. Ex: POST to /foo/bar will serve out /foo/bar_POST.json.


simpl-mock-server -h for help

  • --silent: Disable logging [false]
  • -p: Port to use [8080]
  • --cors: Allow CORS [false]

Status code and Headers

By default all responses (if the file exists) will return a 200 status code. If you want to simulate error conditions or include additional headers, you can add a special meta object to ase the first line of the file (it must be on a single line) starting with *. The valid keys are code and headers.

For example

*{"code": 400}
<response payload>
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free