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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@sinclair/typebox-adapter

v0.9.1

Published

Integrate Valibot and Zod with TypeBox

Readme

npm version Downloads Build License

Install

$ npm install @sinclair/typebox-adapter --save

Example

TypeBox Adapter converts Valibot and Zod Types into TypeBox compatible schematics

TypeScript Example

import { Box } from '@sinclair/typebox-adapter'

import * as v from 'valibot'
import * as z from 'zod'

// Valibot to TypeBox (Runtime)

const V = Box(v.object({                            // const V = {
  x: v.number(),                                    //   type: 'object',
  y: v.number(),                                    //   required: ['x', 'y', 'z'],
  z: v.number()                                     //   properties: {
}))                                                 //     x: { type: 'number' },
                                                    //     y: { type: 'number' },
                                                    //     z: { type: 'number' }
                                                    //   }
                                                    // }

// Zod to TypeBox (Static)

const Z = Box(z.object({                            // const Z: TObject<{
  a: z.string(),                                    //   a: TString,
  b: z.string(),                                    //   b: TString,
  c: z.string()                                     //   c: TString
}))                                                 // }>

Overview

TypeBox Adapter converts Zod and Valibot types into TypeBox schematics (Json Schema). It performs a deep structural remapping of the types provided by these libraries into TypeScript-aligned Json Schema, enabling integration with industry-standard validators like Ajv and OpenAPI-related technologies, while also facilitating interoperability and acceleration via the TypeBox validation infrastructure.

License MIT

Contents

Usage

TypeBox Adapter provides a singular Box function to transform Valibot and Zod types into TypeBox schematics. The top-level export is capable of transforming both Valibot and Zod, but you should use the appropriate submodule depending on which library you are using.

Valibot

Use the /valibot submodule if you only have Valibot installed. Refer to the Valibot documentation for more information on this type library.

import { Box } from '@sinclair/typebox-adapter/valibot' // Transform Valibot Only

import * as v from 'valibot'

const T = Box(v.string())                               // const T = { type: 'string' }

Zod

Use the /zod submodule if you only have Zod installed. Refer to the Zod documentation for more information on this type library.

import { Box } from '@sinclair/typebox-adapter/zod'     // Transform Zod Only

import * as z from 'zod'

const T = Box(z.string())                               // const T = { type: 'string' }

Benchmark

This project manages a benchmark that evaluates type-check performance using Zod, Valibot, and TypeBox validators. The benchmark is set up to run 10 million check operations per library-validator pairing and reports the elapsed time taken to complete.

Type

Benchmarks are run for the following type.

type T = { x: number, y: string, z: boolean }

Results

Results show validate performance for the type.

┌─────────┬────────────────┬────────────────────┬────────────┬────────────┐
│ (index) │ library        │ using              │ iterations │ elapsed    │
├─────────┼────────────────┼────────────────────┼────────────┼────────────┤
│ 0       │ 'valibot     ' │ 'valibot         ' │ 10000000   │ '1534 ms ' │
│ 1       │ 'valibot     ' │ 'typebox:value   ' │ 10000000   │ '1377 ms ' │
│ 2       │ 'valibot     ' │ 'typebox:compile ' │ 10000000   │ '46 ms   ' │
└─────────┴────────────────┴────────────────────┴────────────┴────────────┘
┌─────────┬────────────────┬────────────────────┬────────────┬────────────┐
│ (index) │ library        │ using              │ iterations │ elapsed    │
├─────────┼────────────────┼────────────────────┼────────────┼────────────┤
│ 0       │ 'zod         ' │ 'zod             ' │ 10000000   │ '4669 ms ' │
│ 1       │ 'zod         ' │ 'typebox:value   ' │ 10000000   │ '1359 ms ' │
│ 2       │ 'zod         ' │ 'typebox:compile ' │ 10000000   │ '47 ms   ' │
└─────────┴────────────────┴────────────────────┴────────────┴────────────┘

For community benchmarks, refer to the runtime-type-benchmarks project.

Contribute

This project is open to community contributions. Please ensure you submit an open issue before creating a pull request. TypeBox and its associated projects encourage open community discussion before accepting new features.