When a JSON File Is All the Database You Need - Notepad

When a JSON File Is All the Database You Need

This very website stores its resume, articles, to-do items and contact messages in a data/ folder full of JSON files. No database, no ORM, no migrations.

When it works

  • The data is small (kilobytes, not gigabytes).
  • There is a single writer, or writes are rare.
  • You want the data to be human-readable and diffable in git.

When it does not

  • Multiple server instances need to write the same data.
  • You need transactions, indexes or complex queries.
  • The data contains secrets or personal information that should be encrypted at rest.

A tiny safety net

Even for toy projects it is worth doing two things: serialise writes so two requests cannot clobber each other, and write to a temporary file then rename it so a crash mid-write never leaves you with half a JSON file.

await fs.writeFile(tmp, JSON.stringify(data, null, 2));
await fs.rename(tmp, target);

That is roughly ten lines of code and buys you a lot of peace of mind.

« Back to Articles

168 words
August 2, 2026