npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

to-valibot

v1.5.0

Published

Utility to convert JSON Schemas and OpenAPI Declarations to [Valibot](https://valibot.dev) schemas.

Readme

(OpenAPI Declaration, JSON Schema) to Valibot

Utility to convert JSON Schemas and OpenAPI Declarations to Valibot schemas.

Example usage

1. Converting list of OpenAPI Declarations in .json format to Valibot

import { valibotGenerator } from "to-valibot";

const { generate } = valibotGenerator({
  outDir: "./src/types",
});

const schemas = await Promise.all([
  fetch("http://api.example.org/v2/api-docs?group=my-awesome-api").then(r => r.json()),
  fetch("http://api.example.org/v2/api-docs?group=other-api").then(r => r.json()),
  fetch("http://api.example.org/v2/api-docs?group=legacy-api").then(r => r.json()),
]);

await generate({
  format: 'openapi-json',
  schemas,
});

2. Converting OpenAPI Declarations in .yaml format to Valibot

import { readFile } from "node:fs/promises";;
import { valibotGenerator } from "to-valibot";

const { generate } = valibotGenerator({
  outDir: "./src/types",
});

const schema = readFile("./declarations/my-awesome-api.yaml");

await generate({
  format: 'openapi-yaml',
  schema,
});

3. Converting JSON Schema to Valibot

import { readFile } from "node:fs/promises";;
import { valibotGenerator } from to-valibot";
import schema from "~/schemas/my-api.json";

const { generate } = valibotGenerator({
  outDir: "./src/types",
});

await generate({
  format: 'json',
  schema,
});

3. Provide name to your schemas

import { readFile } from "node:fs/promises";;
import { valibotGenerator } from to-valibot";
import schema from "~/schemas/my-api.json";

const { generate } = valibotGenerator({
  outDir: "./src/types",
});

await generate({
  format: 'json',
  schemas: {
    "My Awesome API Schema": schema // will output to `./src/types/my-awesome-api-schema.ts`
  },
});

API

valibotGenerator

valibotGenerator accepts options object with these parameters

| Name | Type | Required | Description | | ------- | ------- | --------- | ----------------------------------------------------------------- | | outDir | string | yes | Declare in which directory generated schema(s) should be written |

generate

generate function returned by valibotGenerator accepts different set of options, depending on format.

| Name | Type | Required | Description | | -------- | -------------- | --------- | --------------------------------------------- | | format | 'openapi-yaml' | yes | Format specification for the generated output | | schema | string | no* | Single schema to be processed | | schemas | string[] | no* | Multiple schemas to be processed | * Either schema OR schemas must be provided, but not both.

| Name | Type | Required | Description | | -------- | ------------------------ | --------- | --------------------------------------------- | | format | 'openapi-json' | 'json' | yes | Format specification for the generated output | | schema | string | object | no* | Single schema to be processed | | schemas | (string | object)[] | no* | Multiple schemas to be processed | * Either schema OR schemas must be provided, but not both.

Supported features

Same set of features are supported both in OpenAPI Declarations and JSON Schemas

| Feature | Status | Note | | ------------------------------- | ------ | ------------------------------------------------------------------- | | required | ✅ | | | description | ✅ | | | const | ⚠️ | Only works with primitive values | | - | - | - | | string | ✅ | | | enum | ✅ | | | minLength | ✅ | | | maxLength | ✅ | | | pattern | ✅ | | | format="email" | ✅ | | | format="uuid" | ✅ | | | format="date-time" | ✅ | | | format="date" | ✅ | | | format="time" | ✅ | | | format="duration" | ✅ | Custom regex validation | | format="idn-email" | ✅ | Custom regex validation | | format="hostname" | ✅ | Custom regex validation | | format="idn-hostname" | ✅ | Custom regex validation | | format="ipv4" | ✅ | | | format="ipv6" | ✅ | | | format="json-pointer" | ✅ | Custom regex validation | | format="relative-json-pointer" | ✅ | Custom regex validation | | format="uri" | ✅ | Uses Valibot's url() | | format="uri-reference" | ✅ | Custom regex validation | | format="uri-template" | ✅ | Custom regex validation | | format="iri" | ✅ | Uses Valibot's url() | | format="iri-reference" | ✅ | Custom regex validation | | - | - | - | | number | ✅ | | | integer | ✅ | | | exclusiveMaximum | ✅ | | | exclusiveMinium | ✅ | | | maximum | ✅ | | | minium | ✅ | | | multipleOf | ✅ | | | - | - | - | | array | ⚠️ | Only single array item kind is supported for now | | minItems | ✅ | | | maxItems | ✅ | | | uniqueItems | ✅ | Custom validation from to-valibot/client | | prefixItems | ✅ | Maps to Valibot tuple() and tupleWithRest() | | contains | ✅ | Custom validation from to-valibot/client | | minContains | ✅ | Custom validation from to-valibot/client | | maxContains | ✅ | Custom validation from to-valibot/client | | - | - | - | | object | ✅ | | | propertyNames | ✅ | Custom validation from to-valibot/client | | patternProperties | ✅ | Custom validation from to-valibot/client | | additionalProperties | ✅ | | | minProperties | ✅ | | | maxProperties | ✅ | | | - | - | - | | boolean | ✅ | | | null | ✅ | | | - | - | - | | anyOf | ✅ | | | allOf | ✅ | | | oneOf | ✅ | | | not | ✅ | Type inference not supported - custom validation from to-valibot/client |