镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

JSON Schema validation in Node.js core #62598

Description

@mertcanaltin

What is the problem this feature will solve?

Hi all,

I wanted to open a discussion about whether JSON Schema validation could be a useful addition to Node.js core.

Current state

  • Node.js currently has no built-in JSON Schema validation
  • node.config.json (experimental) uses hand-written type checking against a JSON Schema 2020-12 definition generated from C++ option metadata
  • package.json parsing uses simdjson but has no schema validation, fields are extracted structurally
  • The only schema validation in the Node.js tree lives inside deps/npm (Ajv)

Potential use cases

  • Validate node.config.json against its own schema properly
  • Future validation for package.json fields (opt-in, non-breaking)
  • Expose as a built-in module (node:jsonschema) so userland doesn't need to pull in external validators

Context

I've been working on a project in this area, ata-validator, a JSON Schema validator built on simdjson and RE2. It currently passes 96.9% of the official JSON Schema Test Suite (Draft 2020-12) and falls back to a pure JS engine when native bindings aren't available.

I'm not proposing to land it as-is, I'd love to hear from the group first:

  1. Is there interest in having JSON Schema validation available in core?
  2. What would be the most useful entry point? (config validation, public API, both?)
  3. Any concerns about the dependency story? (RE2/abseil weight, simdjson already in core)

Happy to share benchmarks or more details if this sounds worth exploring.

fyi @Qard

What is the feature you are proposing to solve the problem?

A built-in JSON Schema validator, potentially exposed as node:jsonschema, that could also be used internally for validating node.config.json and other configuration files.

This would provide Node.js users with a fast, native JSON Schema (Draft 2020-12) validation capability without needing external dependencies.

What alternatives have you considered?

  • Continuing with hand-written validation for each config format individually,
    doesn't scale as more config formats are added

  • Bundling an existing JS-based validator like Ajv into core, lacks native performance benefits

  • Leaving JSON Schema validation entirely to userland

Activity

  1. nabeel378 commented on Apr 5, 2026

    @nabeel378
    Contributor

    This sounds interesting! Having built-in validation for node.config.json
    against its existing schema would be a practical first step. Looking forward
    to seeing the benchmarks.

  2. marco-ippolito commented on Apr 5, 2026

    @marco-ippolito
    Member

    Would like to see the validation for node.config.json

  3. SukeshP1995 commented on Apr 5, 2026

    @SukeshP1995

    It is sad to see that only ajv is the popular library for json-scema validation. I would like to have native json-schema validation in node itself.

  4. mertcanaltin commented on Apr 5, 2026

    @mertcanaltin
    MemberAuthor

    Would like to see the validation for node.config.json

    I've discussed this with @Qard as well, starting with node.config.json validation sounds like a great first step.
    I'll work on a draft PR for that

  5. Qard commented on Apr 5, 2026

    @Qard
    Member

    We've already discussed it privately, but I think this is worth at least evaluating having it in core. The current design seems to align very well with our performance efforts, even relying on some libraries we already depend on. So the lift to integrate this seems low while the benefit seems high given how many apps need to do input validation and the cost it can have. I also think it's a fairly mechanical need and not like typical libraries where design opinions could be involved--jsonschema works a particular way, and it's a widely accepted standard, so having it in core I think makes sense.

  6. mertcanaltin commented on Apr 5, 2026

    @mertcanaltin
    MemberAuthor

    I opened a PR for node.config.json #62603

  7. joyeecheung commented on Apr 5, 2026

    @joyeecheung
    Member

    I think node.config.json would be a good use case for this since it has a proper schema. For package.json it makes less sense - it's in a performance sensitive path, all the fields are optional, we generally only parse each file once, or lazy parse as much as possible (for imports/exports), and the happy path assumes all fields if present are valid - adding a round of eager schema validation would defeat the optimizations or introduce regressions e.g. when the fields are invalid, most of them have always been silently ignored.

    The strongest use case would be a public module for validating untrusted input. Though that would require the underlying implementation to have e.g. good DoS resistance and proper security handling process first.

  8. 8 remaining items

  9. damianremington274-blip commented on Apr 8, 2026

    @damianremington274-blip
  10. mertcanaltin commented on Apr 24, 2026

    @mertcanaltin
    MemberAuthor

    I'm very happy right now. I just saw @sheplu 's work on validation, and I'm really glad that we'll be solving this problem and collaborating on it with such a great team, I guess we made a node:json or schema team :D
    Let me give you a quick update on the current direction. As you may have seen in the issue, we already have ongoing work for node.config.json (#62603). After that, we were planning to move toward an API design, similar to @sheplu's work (#62927 (comment)).
    Now, working together on an API design and discussing it would be great. In general, we've received these suggestions this api names from the community:

    node:schema, focused on JSON Schema

    node:jsonschema, more specific

    node:json, broader, covering both parsing and validation together (ata already vendors simdjson)

    Looking forward to hearing your thoughts on this.

    fyi @sheplu @lemire @H4ad @Qard @ljharb @mcollina

  11. mcollina commented on Apr 25, 2026

    @mcollina
    SponsorMember

    I don't think we should be adding 3 new subsystems to core for this.

  12. added
    tsc-agendaIssues and PRs to discuss during Technical Steering Committee meetings.
    on Apr 25, 2026
  13. mertcanaltin commented on Apr 25, 2026

    @mertcanaltin
    MemberAuthor

    node:schema, focused on JSON Schema

    node:jsonschema, more specific

    node:json, broader, covering both parsing and validation together (ata already vendors simdjson)

    I think I explained it incorrectly, these were name suggestions. I didn’t mean three separate layers, I meant what the API name should be.

  14. sheplu commented on Apr 25, 2026

    @sheplu
    Member

    I am glad that I am not the only one finding interesting / nice to have a solution to validate json directly in core. Trying to think about the next steps, I think that node:json or node:jsonschema would be better (node:jsonschema for me) which would allow for any kind of "validator" something that would be node:jsonschema/validator.

    @mertcanaltin are you ok if we use the PR I opened to see and get feedback from the publicly facing part of the API - or do we want all the discussion here?

  15. mertcanaltin commented on Apr 25, 2026

    @mertcanaltin
    MemberAuthor

    node:jsonschema works for me. The subpath idea (node:jsonschema/validator) is nice, leaves room for future extensions without locking the surface early.

    I'd lean toward keeping API direction here on #62598 since it's on the TSC agenda and the broader group is subscribed. Your PR (#62927) is a useful concrete reference for what a prototype looks like.

    Once the TSC has weighed in on whether one module makes sense in core at all, we can sync on the API design and whether your PR or a fresh one ends up being the implementation track.

  16. joyeecheung commented on May 13, 2026

    @joyeecheung
    Member

    Should this issue still stay on the TSC agenda? This has been on 3 TSC meetings so probably has served its purpose as FYI?

  17. mertcanaltin commented on May 17, 2026

    @mertcanaltin
    MemberAuthor

    Should this issue still stay on the TSC agenda? This has been on 3 TSC meetings so probably has served its purpose as FYI?

    Thanks for checking @joyeecheung.

    Agree it has served its purpose. we have direction on naming (node:jsonschema, possibly with subpaths) and a first concrete target (node.config.json in #62603). @sheplu has a public API prototype in #62927.

    Happy to take it off the agenda. I'll bring the implementation work back to the TSC when there's something concrete to decide on, either through this issue or the PRs.

  18. Delapouite commented on May 20, 2026

    @Delapouite
    Contributor

    Somehow off-topic, but here are fresh news that may interest contributors about the current state of JSON Schema spec with an article wrap-up of the JSON Schema Conf containing a few interesting points regarding the overall stability of the spec and the multiple-drafts situation:

    https://json-schema.org/blog/posts/apidays-paris-2025-recap

    The conference opened with Jason Desrosiers @jdesrosiers, JSON Schema Specification and Tooling Architect at Hyperjump Software, Inc, presenting “JSON Schema v1 — No More Drafts.”

    The session explored the future direction of JSON Schema and addressed one of the ecosystem’s longest-standing concerns around drafts, versioning, and compatibility. The proposed v1 direction introduces a more stable and predictable evolution model aimed at reducing migration friction while giving users greater confidence in long-term schema maintenance.

  19. removed
    tsc-agendaIssues and PRs to discuss during Technical Steering Committee meetings.
    on May 20, 2026
  20. jdesrosiers commented on May 20, 2026

    @jdesrosiers
  21. github-actions commented on Aug 19, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 90 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  22. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Aug 19, 2026
  23. removed
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions