🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

zod-codecs

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zod-codecs

Library of useful pre-build Codecs for Zod.

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

zod-codecs

A library of useful pre-built codecs for Zod validation.

Installation

npm install zod zod-codecs

Usage

Import codecs from the package and use them with Zod's codec() method:

import { z } from 'zod';
import { stringToInt } from 'zod-codecs';

// Parse a string as an integer
const result = stringToInt.parse('42');
console.log(result); // 42 (number)

// Encode back to string
const encoded = stringToInt.encode(42);
console.log(encoded); // '42' (string)

Available Codecs

String to Number Codecs

  • stringToInt - Converts string to integer number
  • stringToNumber - Converts string to number (including floats)
  • stringToBigint - Converts string to bigint

Date Codecs

  • isoDateTimeToDate - Converts ISO date-time string to Date object
  • unixSecondsToDate - Converts Unix timestamp (seconds) to Date object

Binary Data Codecs

  • base64ToUint8Array - Converts base64 encoded string to Uint8Array
  • base64urlToUint8Array - Converts URL-safe base64 encoded string to Uint8Array
  • hexToUint8Array - Converts hexadecimal string to Uint8Array

URL Codecs

  • stringToUrl - Converts URL string to URL object
  • queryStringToMap - Converts query string to Map<string, string>
  • queryStringToObject - Converts query string to Record<string, string>

Keywords

zod

FAQs

Package last updated on 20 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts