apidoc and swagger-jsdoc are both tools that generate interactive API documentation by parsing specially formatted comments in JavaScript (or TypeScript) source code. They aim to keep documentation close to implementation, reduce duplication, and produce human-readable specs without writing raw OpenAPI/Swagger YAML or JSON. However, they target different documentation standards and ecosystems: apidoc uses its own lightweight format and produces standalone HTML docs, while swagger-jsdoc builds valid OpenAPI 3.0 (or Swagger 2.0) specifications that integrate with the broader Swagger ecosystem like Swagger UI or Redoc.
Both apidoc and swagger-jsdoc help you avoid writing separate API documentation by extracting structured info from code comments. But they diverge sharply in output format, ecosystem alignment, and long-term maintainability. Let’s break down what really matters when you’re building production-grade APIs.
apidoc uses its own set of JSDoc-like tags that are easy to learn but proprietary.
@api, @apiParam, @apiSuccess, etc., directly above route handlers./**
* @api {get} /user/:id Get User Info
* @apiName GetUser
* @apiGroup User
*
* @apiParam {Number} id Users unique ID.
*
* @apiSuccess {String} firstname Firstname of the User.
* @apiSuccess {String} lastname Lastname of the User.
*/
app.get('/user/:id', (req, res) => {
// ...
});
swagger-jsdoc embeds fragments of OpenAPI spec inside JSDoc comments using @openapi or @swagger.
/**
* @openapi
* /user/{id}:
* get:
* summary: Get User Info
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: integer
* responses:
* '200':
* description: A user object
* content:
* application/json:
* schema:
* type: object
* properties:
* firstname: { type: string }
* lastname: { type: string }
*/
app.get('/user/:id', (req, res) => {
// ...
});
apidoc generates a complete, static HTML website with navigation, search, and examples.
swagger-jsdoc outputs a valid OpenAPI 3.0 JSON or YAML file.
openapi-typescript), reducing manual typing errors.// swagger-jsdoc: generate spec, then serve via Swagger UI
const swaggerSpec = swaggerJsdoc(options);
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));
apidoc lives in its own world.
swagger-jsdoc plugs into the OpenAPI ecosystem.
swagger-parser to validate your generated spec.eslint-plugin-openapi to catch comment errors during development.express-openapi-validator) and frontend (for type-safe API calls).// Example: Validate incoming requests using the same spec
const validator = require('express-openapi-validator');
app.use(validator({ apiSpec: swaggerSpec }));
apidoc hasn’t kept pace with modern API practices.
User model used across endpoints).swagger-jsdoc leverages OpenAPI’s full feature set.
components.schemas.User) once and $ref them everywhere./**
* @openapi
* components:
* schemas:
* User:
* type: object
* properties:
* id: { type: integer }
* name: { type: string }
*/
// Later, reference it:
// responses:
// '200':
// content:
// application/json:
// schema:
// $ref: '#/components/schemas/User'
Despite their differences, both tools share common ground that makes them appealing over hand-written docs:
{
"scripts": {
"docs:apidoc": "apidoc -i src/ -o docs/",
"docs:swagger": "node scripts/generate-swagger.js"
}
}
| Feature | apidoc | swagger-jsdoc |
|---|---|---|
| Output | Static HTML site | Valid OpenAPI 3.0 JSON/YAML |
| Comment Style | Proprietary @api* tags | Embedded OpenAPI fragments |
| Ecosystem | Standalone | Integrates with Swagger tooling |
| Reusability | Limited (no shared models) | Full $ref support for schemas |
| Frontend Utility | Human-readable only | Enables type-safe clients & mocks |
| Future-Proofing | Low — locked to apidoc format | High — aligned with industry standard |
Use apidoc if you’re building a small internal API and just need a quick, readable HTML page for your team — and you’re confident you’ll never need machine-readable contracts.
Use swagger-jsdoc if you’re working on anything customer-facing, cross-team, or likely to grow. The upfront learning curve of OpenAPI pays off through automation, type safety, and tooling that scales with your project.
In today’s frontend landscape — where APIs drive everything from React hooks to mobile apps — treating your API spec as a first-class artifact (not just documentation) is non-negotiable. That’s why swagger-jsdoc is the more sustainable choice for professional teams.
Choose apidoc if you need a simple, zero-config way to generate clean, self-contained HTML documentation directly from JSDoc-style comments and don’t require strict OpenAPI compliance. It’s well-suited for internal APIs or teams that prioritize ease of setup over interoperability with tooling that expects standard OpenAPI specs. Avoid it if your organization mandates OpenAPI/Swagger for contract testing, code generation, or gateway integration.
Choose swagger-jsdoc if your project must produce valid OpenAPI 3.0 (or Swagger 2.0) definitions that plug into the wider Swagger ecosystem — including Swagger UI, Postman imports, contract validation, or client SDK generation. It’s ideal when documentation must serve as a machine-readable contract between frontend and backend teams, or when you’re already using OpenAPI elsewhere in your pipeline.
apiDoc creates a documentation from API descriptions in your source code.
$ npm install -g apidoc
Add some apidoc comments anywhere in your source code:
/**
* @api {get} /user/:id Request User information
* @apiName GetUser
* @apiGroup User
*
* @apiParam {Number} id User's unique ID.
*
* @apiSuccess {String} firstname Firstname of the User.
* @apiSuccess {String} lastname Lastname of the User.
*/
Now generate the documentation from src/ into doc/.
$ apidoc -i src/ -o doc/
This repository contains and example folder from which you can generate a very complete documentation on an example api endpoint. It also contains best practice hints (in the footer.md file).
$ git clone https://github.com/apidoc/apidoc && cd apidoc
$ npm install --prod
$ ./bin/apidoc -i example -o /tmp/doc
$ $BROWSER /tmp/doc
You can generate the documentation programmatically:
import path from 'path'
import { createDoc } from 'apidoc'
const doc = createDoc({
src: path.resolve(__dirname, 'src'),
dest: path.resolve(__dirname, 'doc'), // can be omitted if dryRun is true
// if you don't want to generate the output files:
dryRun: true,
// if you don't want to see any log output:
silent: true,
})
if (typeof doc !== 'boolean') {
// Documentation was generated!
console.log(doc.data) // the parsed api documentation object
console.log(doc.project) // the project information
}
Install type definitions (see @types/apidoc):
$ npm install -D @types/apidoc
You can use apidoc in Docker like this:
# first build the image after cloning this repository
docker build -t apidoc/apidoc .
# run it
docker run --rm -v $(pwd):/home/node/apidoc apidoc/apidoc -o outputdir -i inputdir
C#, Go, Dart, Java, JavaScript, PHP, Scala (all DocStyle capable languages):
/**
* This is a comment.
*/
Clojure:
;;;;
;; This is a comment.
;;;;
CoffeeScript:
###
This is a comment.
###
Elixir:
#{
# This is a comment.
#}
Erlang:
%{
% This is a comment.
%}
Perl
#**
# This is a comment.
#*
=pod
This is a comment.
=cut
Python
"""
This is a comment.
"""
Ruby
=begin
This is a comment.
=end
apiDoc will auto include installed plugins.
npm install apidoc-plugin-schemaFor details and an example on how to implement your own plugin, please view apidoc-plugin-test.
Please create a new issue if you have a suggestion/question or if you found a problem/bug.
apiDoc is a collaborative project. Pull requests are welcome. Please see the CONTRIBUTING file.
pip install flask-apidocnpm install grunt-apidoc.npm install gapidoc.npm install --save-dev webpack-apidoc.