On this page

The command-line interface of doc-kit, the Node.js project's toolkit for API documentation. Its doc-kit command reads your docs and runs generators that write a website, the search index, JSON, llms.txt, man pages, or whatever a custom generator produces. Use it to build your docs locally and in CI.

The CLI comes with @doc-kit/core and its JSON generators. The other generators live in their own packages, which you install next to the CLI. The command above adds the website generators; leave @doc-kit/generator-react out if you only need JSON.

PackageGenerators
@doc-kit/corejson, json-all, json-simple
@doc-kit/generator-reacthtml, section-pages, orama-db, sitemap, llms-txt, llms-txt-full
@node-core/doc-kitman-page, api-links, addon-verify

This builds the website and its search index from every Markdown file under docs/, and writes them to out/. A run needs at least a target and an input, from flags or a configuration file:

  • -t, --target <generator...> string[] The generators to run. Repeat the flag, or list several names after it.
  • -i, --input <patterns...> string[] Glob patterns matching your source files. Quote them, so your shell passes them on unexpanded.
  • -o, --output <directory> string The directory the generators write to.

Run npx doc-kit generate --help, or see the CLI reference, for every option.

This serves ./out on http://localhost:3000 as it is, without reading your configuration file. Pass it any generate option and it builds first, then serves the directory that build wrote to. If your build writes somewhere other than ./out, pass your configuration file (or -o) so it builds and serves that directory:

It builds once and doesn't watch for changes, so run it again after editing. Two options of its own control the server:

  • --port <number> number The port to serve on. Default: 3000.
  • --host <host> string The host to listen on. Default: 'localhost'.
Note

The preview server is meant for checking your docs locally. To put them online, upload the output directory to a static host; see Publishing your docs.

Instead of passing flags on every run, put your options in a configuration file:

export default {
  target: ['html', 'orama-db'],

  global: {
    input: ['docs/**/*.md'],
    output: 'out',
  },
};

With this file in place, npx doc-kit generate needs no flags. doc-kit looks for it in the working directory, as doc-kit.config.mjs (or .js, .cjs), a .doc-kitrc file in JSON, YAML or JavaScript, or a doc-kit key in package.json. Pass --config-file <path> to load another file. A flag wins over the file when both set the same option.

The configuration reference covers every option, including each generator's own.

--target, and target in the configuration file, also take a generator you wrote or installed: a relative path such as ./my-generator.mjs (resolved from the working directory), an absolute path, or a package name. The module's default export must have a name and a generate function.

Creating generators shows how to write one.

--log-level <level> works with every command. It takes debug, info, warn, error or fatal, and defaults to info:

This package lives in packages/cli of the nodejs/doc-kit monorepo, which uses Node.js 24 and pnpm:

git clone https://github.com/nodejs/doc-kit.git
cd doc-kit
pnpm install

# Run the CLI from source
node --run run -- generate --help

# Run it again whenever a file it imports changes
node --run watch -- generate -t json -i "path/to/docs/**/*.md" -o out

Each command is a module in bin/commands/; Adding a command walks through writing one. Run the tests with node --run test, and add a changeset with node --run changeset for any change users will notice. The contributing guide has the rest.