Zod safeParse vs parse

Benchmark created on


Description

Testing Zod parsing performance

Preparation HTML

<script type="module" src="https://cdn.jsdelivr.net/npm/zod@3.21.4/lib/index.mjs">

Setup

import { z } from "https://cdn.jsdelivr.net/npm/zod@3.21.4/lib/index.mjs";
const schema = z.object({ a: z.string(), b: z.string().optional(), c: z.string().array().optional() })

Test runner

Ready to run.

Testing in
TestOps/sec
safeParse an invalid schema
schema.safeParse('a string')
ready
parse an invalid schema
try {
	schema.parse('a string')
} catch() {}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.