Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including skema with all npm packages installed. Try it out:

var skema = require("skema")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

skema v9.5.5

Skema provides a handy & composable way to validate / transform / purify the input data.

Build Status Coverage


skema provides a handy and composable way to validate/transform JavaScript variables:

  • Supports both async and sync flows. Skema has two working modes to support either async or sync validators, setters, etc, making it capable with much more complicated challenges.

  • NOT only type checker. Unlike TypeScript, joi, and many others, Skema is not only a JavaScript type checker, but also a good solution for your Anti-Corruption Layer (ACL) to transform and purify the input data. And Skema could also be configured as a simple schema validator too.

  • Pluggable basic types. Even basic types such as Number could also be replaced and customized if using Skema. Actually, in the core of Skema, there is NOT a single definition of one type.

  • Powerful custom types. Every single type is able to be customized that you can handle almost everything including descriptor, conditions, default values, validators and so on.

  • Composable structures. You could build a much bigger schema with the small ones into the whole world.


npm i skema

Basic Usage

🔬 Live Demo with JsFiddle

import {shape} from 'skema'

// Schema definitions are ONLY objects.
const User = shape({
  id: 'number?',
  name: String

// Then use these definitions to purify our data.
const user = User.from({
  id: '1',
  name: 'Steve'

// {
//   id: 1,
//   name: 'Steve'
// } = 'boooom!'
// throw TypeError
// - message: 'not a number'


Many Examples

Related Packages

  • @skema/basic The default built-in javascript types of skema.




RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free