All Projects â†’ typicode â†’ Lowdb

typicode / Lowdb

Licence: mit
Simple to use local JSON database (supports Node, Electron and the browser)

Programming Languages

184084 projects - #8 most used programming language
77523 projects

Projects that are alternatives of or similar to Lowdb

🌩ī¸ StormDB is a tiny, lightweight, 0 dependency, easy-to-use JSON-based database for NodeJS, the browser or Electron.
Stars: ✭ 406 (-97.6%)
Mutual labels:  json, database, embedded-database, embeddable, localstorage
Nano Sql
Universal database layer for the client, server & mobile devices. It's like Lego for databases.
Stars: ✭ 717 (-95.75%)
Mutual labels:  json, database, localstorage
đŸ”ĨđŸģ The Speakeasy Scripting Engine Which Combines Speed, Safety, and Simplicity
Stars: ✭ 128 (-99.24%)
Mutual labels:  database, embeddable
Record Query - A tool for doing record analysis and transformation
Stars: ✭ 1,808 (-89.29%)
Mutual labels:  json, lodash
Web Database Analytics
Web scrapping and related analytics using Python tools
Stars: ✭ 175 (-98.96%)
Mutual labels:  json, database
Bible Database
Bible databases as XML, JSON, SQL & SQLITE3 Database format for various languages. Developers can download it freely for their development works. Freely received, freely give.
Stars: ✭ 111 (-99.34%)
Mutual labels:  json, database
RadonDB is an open source, cloud-native MySQL database for building global, scalable cloud services
Stars: ✭ 1,584 (-90.62%)
Mutual labels:  json, database
DuckDB is an in-process SQL OLAP Database Management System
Stars: ✭ 4,014 (-76.23%)
Mutual labels:  database, embedded-database
A Persistent Embedded Graph Database for Python
Stars: ✭ 90 (-99.47%)
Mutual labels:  database, embedded-database
Barrel Platform
Distributed database for the modern world
Stars: ✭ 201 (-98.81%)
Mutual labels:  json, database
A JVM-embeddable Distributed Database
Stars: ✭ 192 (-98.86%)
Mutual labels:  database, embeddable
Bow - Minimal embedded database powered by Badger
Stars: ✭ 212 (-98.74%)
Mutual labels:  database, embedded-database
An Embedded NoSQL, Transactional Database Engine
Stars: ✭ 1,583 (-90.63%)
Mutual labels:  json, database
Php Jsondb
A PHP Class that reads JSON file as a database. Use for sample DBs
Stars: ✭ 96 (-99.43%)
Mutual labels:  json, database
Marklogic Data Hub
The MarkLogic Data Hub: documentation ==>
Stars: ✭ 113 (-99.33%)
Mutual labels:  json, database
FileContextCore is a "Database"-Provider for Entity Framework Core and adds the ability to store information in files instead of being limited to databases.
Stars: ✭ 91 (-99.46%)
Mutual labels:  json, database
A Lightweight Cloud based JSON Database with a MongoDB like API for Node.
Stars: ✭ 174 (-98.97%)
Mutual labels:  json, database
A tiny Golang JSON database
Stars: ✭ 218 (-98.71%)
Mutual labels:  json, database
(Migrated from CodePlex) DbWebApi is a .Net library that implement an entirely generic Web API (RESTful) for HTTP clients to call database (Oracle & SQL Server) stored procedures or functions in a managed way out-of-the-box without any configuration or coding.
Stars: ✭ 84 (-99.5%)
Mutual labels:  json, database
In-memory NoSQL database with ACID transactions, Raft consensus, and Redis API
Stars: ✭ 1,295 (-92.33%)
Mutual labels:  json, database

lowdb Node.js CI

Simple to use local JSON database đŸĻ‰

// This is pure JS, not specific to lowdb ;){ id: 1, title: 'lowdb is awesome' })

// Save to file
// db.json
  "posts": [
    { "id": 1, "title": "lowdb is awesome" }

If you like lowdb, see also xv (test runner) and steno (fast file writer).


Become a sponsor and have your company logo here.

Please help me build OSS 👉 GitHub Sponsors


  • Lightweight
  • Minimalist and easy to learn API
  • Query and modify data using plain JS
  • Improved TypeScript support
  • Atomic write
  • Hackable:
    • Change storage, file format (JSON, YAML, ...) or add encryption via adapters
    • Add lodash, ramda, ... for super powers!


npm install lowdb


Lowdb 3 is a pure ESM package. If you're having trouble importing it in your project, please read this.

import { join, dirname } from 'path'
import { Low, JSONFile } from 'lowdb'
import { fileURLToPath } from 'url'

const __dirname = dirname(fileURLToPath(import.meta.url));

// Use JSON file for storage
const file = join(__dirname, 'db.json')
const adapter = new JSONFile(file)
const db = new Low(adapter)

// Read data from JSON file, this will set content

// If file.json doesn't exist, will be null
// Set default data
// = || { posts: [] } // Node < v15.x ||= { posts: [] }             // Node >= 15.x

// Create and query items using plain JS'hello world')[0]

// You can also use this syntax if you prefer
const { posts } =
posts.push('hello world')

// Write content to db.json
await db.write()
// db.json
  "posts": [ "hello world" ]


Lowdb now comes with TypeScript support. You can even type content.

type Data = {
  posts: string[] // Expect posts to be an array of strings
const adapter = new JSONFile<Data>('db.json')
const db = new Low<Data>(adapter)
  .push(1) // TypeScript error 🎉


You can easily add lodash or other utility libraries to improve lowdb.

import lodash from 'lodash'

// ...
// Note: needs to be initialized before lodash.chain is called.
db.chain = lodash.chain(

// Instead of, you can now use db.chain if you want to use the powerful API that lodash provides
const post = db.chain
  .find({ id: 1 })
  .value() // Important: value() needs to be called to execute chain

More examples

For CLI, server and browser usage, see examples/ directory.



Lowdb has two classes (for asynchronous and synchronous adapters).

new Low(adapter)

import { Low, JSONFile } from 'lowdb'

const db = new Low(new JSONFile('file.json'))
await db.write()

new LowSync(adapterSync)

import { LowSync, JSONFileSync } from 'lowdb'

const db = new LowSync(new JSONFileSync('file.json'))


Calls and sets

Note: JSONFile and JSONFileSync adapters will set to null if file doesn't exist. // === null // !== null


Calls adapter.write( = { posts: [] }
db.write() // file.json will be { posts: [] } = {}
db.write() // file.json will be {}


Holds your db content. If you're using the adapters coming with lowdb, it can be any type supported by JSON.stringify.

For example: = 'string' = [1, 2, 3] = { key: 'value' }


Lowdb adapters


Adapters for reading and writing JSON files.

new Low(new JSONFile(filename))
new LowSync(new JSONFileSync(filename))

Memory MemorySync

In-memory adapters. Useful for speeding up unit tests.

new Low(new Memory())
new LowSync(new MemorySync())


Synchronous adapter for window.localStorage.

new LowSync(new LocalStorage(name))

TextFile TextFileSync

Adapters for reading and writing text. Useful for creating custom adapters.

Third-party adapters

If you've published an adapter for lowdb, feel free to create a PR to add it here.

Writing your own adapter

You may want to create an adapter to write to YAML, XML, encrypt data, a remote storage, ...

An adapter is a simple class that just needs to expose two methods:

class AsyncAdapter {
  read() { /* ... */ } // should return Promise<data>
  write(data) { /* ... */ } // should return Promise<void>

class SyncAdapter {
  read() { /* ... */ } // should return data
  write(data) { /* ... */ } // should return nothing

For example, let's say you have some async storage and want to create an adapter for it:

import { api } from './AsyncStorage'

class CustomAsyncAdapter {
  // Optional: your adapter can take arguments
  constructor(args) {
    // ...

  async read() {
    const data = await
    return data

  async write(data) {
    await api.write(data)

const adapter = new CustomAsyncAdapter()
const db = new Low(adapter)

See src/adapters/ for more examples.

Custom serialization

To create an adapter for another format than JSON, you can use TextFile or TextFileSync.

For example:

import { Adapter, Low, TextFile } from 'lowdb'
import YAML from 'yaml'

class YAMLFile {
  constructor(filename) {
    this.adapter = new TextFile(filename)

  async read() {
    const data = await
    if (data === null) {
      return null
    } else {
      return YAML.parse(data)

  write(obj) {
    return this.adapter.write(YAML.stringify(obj))

const adapter = new YAMLFile('file.yaml')
const db = new Low(adapter)


Lowdb doesn't support Node's cluster module.

If you have large JavaScript objects (~10-100MB) you may hit some performance issues. This is because whenever you call db.write, the whole is serialized and written to storage.

Depending on your use case, this can be fine or not. It can be mitigated by doing batch operations and calling db.write only when you need it.

If you plan to scale, it's highly recommended to use databases like PostgreSQL, MongoDB, ...

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].