@adobe/jsonschema2md

中文文档
8.0.11发布于 2026/03/24Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 6.5万

Validate and document complex JSON Schemas the easy way.

原始使用文档
文档目录18 节
  1. JSON Schema Support
  2. Requirements
  3. Example Output
  4. Installing and running
  5. Internationalization
  6. Display custom attributes in the property description
  7. Disable header template
  8. Examples as YAML
  9. Using JSON Schema Markdown Tools from npm
  10. With script
  11. With API for Node.js
  12. Tests
  13. CI
  14. Code Coverage
  15. Style Guide / Linting
  16. TODOs
  17. Contributing
  18. License/Copyright

JSON Schema Markdown Tools

GitHub Actions

Documenting and validating complex JSON Schemas can be hard. This tool makes it easier by providing a number of scripts that can turn JSON Schema files into readable Markdown documentation that is ready for consumption on GitHub or processed using Jekyll or other static site generators.

These tools have been introduced by Adobe to document Adobe's Experience Data Models (XDM), but can be used for other JSON Schema documents, too.

JSON Schema Support

jsonschema2md is developed against JSON Schema 2019-09, but not the full vocabulary is supported. Please check the detailed list of JSON Schema keywords supported by jsonschema2md. This list is updated by our tests.

Requirements

  • npm version 3.10.8 or up
  • node v18 or v20 or up

Example Output

Using the schemas in examples/schemas (note the *.schema.json extension), the output in examples/docs has been generated.

Installing and running

$ npm install -g @adobe/jsonschema2md

# show usage information
$ jsonschema2md

# run task
$ jsonschema2md -d examples/schemas -o examples/docs
# generated output for whole folder is written to ./examples/docs

By default, jsonschema2md looks for schema files ending in *.schema.json. You can specify another extension by using the --schema-extension or -e command line argument.

Internationalization

The generated documentation can be internationalized. Select the language you want to use for the output using the -l parameter.

Supported languages are:

  • English
  • German

If you want to provide a translation of your own, please use GitLocalize

Display custom attributes in the property description

jsonschema2md displays only the attributes of an property which are defined by the JSON Schema standard. If you want to display additional attributes in the property description you could provide these with the --properties (or -p) parameter.

# include both the `version` and the `test` attribute
$ jsonschema2md -d examples/schemas -o examples/docs -p version -p test

Disable header template

In some cases you do not need a header because it does not provide any useful information. With the --header (or -h) parameter you can disable the inclusion of headers.

# run against JSON Schema Draft 06
$ jsonschema2md -d examples/schemas -o examples/docs -v 06 -h false

Examples as YAML

If you are using JSON Schema to validate YAML documents, for instance configuration files, you might wish for examples to be formatted as YAML, not JSON. Using the command line option -f yaml or --example-format yaml achieves this goal.

Using JSON Schema Markdown Tools from npm

You can conveniently use the JSON Schema Markdown Tools from npm. This makes it possible to set up a conversion toolchain for your JSON Schema project that is driven entirely by npm. To do so, first define the dependency by adding this to your "devDependencies" section of package.json

  "devDependencies": {
    "@adobe/jsonschema2md": "^6.0.0"
  }

With script

Then add the following to the "scripts" section of your package.json and adapt accordingly:

"scripts": {
  "prepare": "mkdir -p docs/reference && jsonschema2md -o docs/reference -d schemas/draft-04"
}

If you run npm install before running npm run prepare, npm will install the @adobe/jsonschema2md in a node_modules/.bin path, even if you did not install the JSON Schema Markdown beforehand.

With API for Node.js

const {jsonschema2md} = require('@adobe/jsonschema2md');
const schema = require('examples/schemas/example.schema.json');

const markdown = jsonschema2md(schema, {
  includeReadme: true,
});

Tests

Ensure you have all the dependencies installed via npm install, then run:

npm test

This will run our Jasmine test suite as well as lint the JavaScript according to our style guide (see below).

CI

Continuous integration runs on Github Actions. All pull requests automatically trigger a job that runs the tests by executing the main.yml.

Code Coverage

npm run test will generate a code coverage report at the end of the test run. Anything below 100% coverage counts as a test failure.

Style Guide / Linting

This project uses eslint to enforce JavaScript coding style. To run the linter:

npm run lint

TODOs

Add support for missing keywords

Contributing

Please see Contributing.md for details. Pull requests are welcome.

License/Copyright

Copyright 2017 Adobe Systems Incorporated. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

版本与发布记录

@adobe/jsonschema2md 共发布 208 个版本,首次发布于 2017/12/06;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.0.11latest2026/03/247 个月前
8.0.102026/01/0610 个月前
8.0.92025/12/1510 个月前
8.0.82025/11/1511 个月前
8.0.72025/10/171.1 年前
8.0.62025/09/301.1 年前

关于 @adobe/jsonschema2md 的常见问题

@adobe/jsonschema2md 是什么?

Validate and document complex JSON Schemas the easy way.

如何安装 @adobe/jsonschema2md?

在项目目录运行 npm install @adobe/jsonschema2md,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 jsonschema2md,可以用 npx jsonschema2md 直接运行。

@adobe/jsonschema2md 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@adobe/jsonschema2md 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@adobe/jsonschema2md 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^18.0.0 || >= 20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@adobe/jsonschema2md 可以商用吗?

@adobe/jsonschema2md 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@adobe/jsonschema2md 的下载量有多少?

根据 npm 官方下载统计,@adobe/jsonschema2md 在 2026/10/05 – 2026/11/03 这 30 天内被下载 65,438 次,日均约 2,181 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@adobe/jsonschema2md 还在维护吗?

最新版本 8.0.11 发布于 2026/03/24(7 个月前);至今共发布 208 个版本,其中过去 12 个月发布了 4 个;首次发布于 2017/12/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。