Node.js online compiler

Node.js 26 with fs, http, Express and more, simulated in your browser. Runs in your browser.

Learn Node.js & Express →
server.js
// Online Node.js compiler
// A Node.js 26 runtime simulated in your browser: fs, http, crypto, node:test,
// node:sqlite and packages such as express and zod are available.
import express from 'express';

const app = express();
app.use(express.json());

const todos = [{ id: 1, title: 'Learn Node.js', done: false }];

app.get('/todos', (req, res) => res.json(todos));
app.post('/todos', (req, res) => {
  const todo = { id: todos.length + 1, title: req.body.title, done: false };
  todos.push(todo);
  res.status(201).json(todo);
});

const server = app.listen(3000, () => console.log('Listening on http://localhost:3000'));

// Call the server, as a browser or frontend would:
await fetch('http://localhost:3000/todos', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ title: 'Build an API' }),
});
const res = await fetch('http://localhost:3000/todos');
console.log(res.status, await res.json());

server.close();
Output

Press ▶ Run or Ctrl/⌘ + Enter to run your code.

Servers you start can be called with fetch("http://localhost:3000"). Packages: express, zod, bcryptjs, jsonwebtoken, graphql, cors, helmet.