Validate unknown runtime data.
Infer reliable types.
An ultra-fast, composable schema validation engine for JavaScript and TypeScript. Built with dual sync/async parsing, prototype-pollution defenses, and direct static type derivation.
Clean Validated Output
Data passes through isolated parsing contexts. Prototype injection keys like __proto__ are strictly neutralized, transformations applied, and static type guarantees emitted.
const result = User.safeParse(input); // result.success: true // result.data.username === "alexdev" // result.data.age === 28 (coerced number)
Interactive Evaluation
Try Subatom Infer in Real Time
Click through runtime scenarios to see how types are safely coerced, constraints validated, and malicious prototype keys stripped.
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"username": " DeveloperAlex ",
"email": "alex@subatomjs.dev",
"age": "26",
"role": "admin"
}{
"success": true,
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"username": "developeralex",
"email": "alex@subatomjs.dev",
"age": 26,
"role": "admin"
}
}Core Architecture
Engineered for High-Throughput Boundaries
Designed to run anywhere data crosses trust boundaries without performance penalties or external vulnerabilities.
Dual Sync/Async Engine
Blazing fast synchronous validation for CPU-bound pipelines, with automated branching into async routines when Promises or database checks are used.
Prototype Pollution Defense
Automatic defense against __proto__ and constructor injections across object shapes, records, and merged schemas.
First-Class File Uploads
Dedicated infer.file() and infer.files() schemas with MIME checks, file extension limits, size thresholds, and storage policies.
Smart Coercion Suite
Safely convert strings from URL queries and multipart forms into typed booleans, numbers, bigints, and dates via infer.coerce.*.
O(1) Discriminated Unions
Indexed tag lookup delivers constant-time branch resolution for event payloads and state machines without test-and-fail iterations.
Zero Dependencies
Zero external runtime dependencies. Lightweight dual ESM and CommonJS bundle with 100% test branch coverage.
Clean Developer Experience
Idiomatic JavaScript & TypeScript Syntax
Switch between TypeScript and plain JavaScript examples anywhere in the documentation.
import { infer, type Infer } from "subatom-infer";
// 1. Define schema with chaining & constraints
export const RegisterSchema = infer.object({
id: infer.string().uuid(),
handle: infer.string().min(3).max(24).toLowerCase().trim(),
email: infer.string().email(),
age: infer.coerce.number().int().min(18).optional(),
plan: infer.enum(["free", "pro", "enterprise"]).default("free"),
avatar: infer.file().mime(["image/png", "image/jpeg"]).max(5_000_000).optional(),
joinedAt: infer.coerce.date().default(() => new Date())
}).strict();
// 2. Automatically derive static TypeScript types
export type RegisterInput = Infer<typeof RegisterSchema>;
// 3. Validate runtime payloads safely
const result = RegisterSchema.safeParse(req.body);
if (result.success) {
console.log("Verified User:", result.data.handle);
}Ready to make your application type-safe at runtime?
Explore the complete documentation, learn schema patterns, and integrate Subatom Infer into your Node.js or Next.js app in minutes.
