ArkType

Every package ArkType publishes, its entrypoints, and what to import from each.

To define and validate Types, install arktype. It has zero runtime dependencies and exposes its regex parser, schema layer, and utilities under subpaths (arktype/regex, arktype/schema, arktype/util). Each package publishes under exactly one name, the one listed here; @ark/type, @ark/regex, @ark/schema, @ark/util, @ark/json-schema and the @arktype/* names are no longer published.

PackageInstall it toDocs
arktypedefine Types and validate dataSetup
@ark/aotconstruct your Types when you buildPrecompile
arkregexwrite regular expressions with inferred typesArkRegex
@ark/attestassert types and benchmark them in your testsAttest
@ark/fast-checkgenerate test data from a Type with fast-checkfast-check
@ark/fsnothing: it's the filesystem layer @ark/attest uses

Editor integrations for VS Code (and its forks), JetBrains IDEs, Zed, Neovim and Helix, plus "ArkThemes" for VS Code, are on the Editor page.

arktype

EntrypointImport it for
arktypeeverything you use day to day (below)
arktype/codecscodec, and the .encode every Type has once it's imported (Codecs)
arktype/errorsinstalls errors: "first" and "none" (errors)
arktype/mutatesInputinstalls mutatesInput: true and "always" (mutatesInput)
arktype/regexregex and the Regex type (ArkRegex)
arktype/schemaschema nodes, rootSchema, schemaScope and ArkErrors internals (Internals, not semver-stable)
arktype/utilshared utilities used by ArkType (not semver-stable)
arktype/runtimewhat precompiled validators run on. A build resolves arktype to it; you don't import it yourself
arktype/configconfigure, before anything else from arktype is imported
arktype/locales/en, arktype/locales/dethe en and de locales
arktype/i18nhelpers that a locale uses: listPattern, isolate, labelOf, groupByPath, printedActualOf, describeCause, describeMissing, writeKeywordExpected
arktype/internal, arktype/internal/*.tsevery module's exports, for tools built on ArkType. Not semver-stable.

These entrypoints are arktype's whole public surface. Any other subpath it exports, like arktype/schema/internal, arktype/schema/issueFeatures or arktype/schema/runtime/*, is not semver-stable.

arktype is ES2022 that calls only ES2020 built-ins, so it runs wherever both are supported. CI tests it on the two latest Node LTS lines and Node's current release, Deno, Bun, Chrome and Firefox, and on the TypeScript versions Setup lists.

arktype exports:

  • type, scope, match, generic, declare, define and fn to define Types, and keywords and ark, the keywords as a module and as a scope.
  • fromJsonSchema, which reads a JSON Schema or a Standard JSON Schema, like a Zod schema, into a Type (From JSON Schema).
  • regex, the same function arkregex exports.
  • Type, Module and Generic to check a value with instanceof, and Hkt to write a higher-kinded generic.
  • ArkErrors, TraversalError, ParseError and ToJsonSchemaError, the errors ArkType returns and throws, ArkError, the type of one issue, and Traversal, the type of the ctx a narrow or morph receives.
  • byPath, flatByPath, flatMessagesByPath, byAncestorPath, firstIssue, lineOf and messageIn, which read an ArkErrors or ArkError.
  • annotatingFallback, a JSON Schema fallback, and inferred, the symbol key a Type's inferred type is declared under.
  • types such as Out, Brand, Json, JsonSchema, ArkErrorCode, Locale, Scope, BaseType and inferDefinition/validateDefinition for wrapping type.

arktype exports configure too, but importing it from there loads all of arktype first. Configure in a file of its own, and import that file before anything else:

config.ts
import { configure } from "arktype/config"

configure({ onUndeclaredKey: "delete" })
app.ts
import "./config.ts"
import { type } from "arktype"

arktype also installs an ark CLI (init, migrate, skill, and check, emit and declare via @ark/aot). Outside a project with arktype installed, invoke it as npx arktype rather than npx ark (ark on npm is an unrelated package).

Other packages

  • @ark/aot has an entrypoint for each way to run it: @ark/aot/unplugin (precompile.vite(), .rollup(), .webpack() and the other bundlers), @ark/aot/node (register()), @ark/aot/bun (precompile()), @ark/aot/turbopack (a loader, withPrecompile() for next.config and @ark/aot/turbopack/runtime for its alias) and @ark/aot/eslint (configs.recommended). Its CLI commands run through ark (ark check, ark emit, ark declare, or npx arktype check/emit/declare), and @ark/aot itself exports Precompiler, whose analyze() the CLI and ESLint rule run. It needs Node 22.12 or later, and typescript 5.5 to 6 (or TypeScript 7.1+ via tsgo or tsrs) for declarations. See Setup.
  • arkregex exports regex, which is also exported from arktype, and the Regex type.
  • @ark/attest exports attest, bench, setup and teardown, and installs an attest CLI. Install it as a dev dependency.
  • @ark/fast-check exports arkToArbitrary. It needs fast-check 3 or 4 installed beside it.

@ark/fast-check and @ark/attest each peer on an exact version of arktype, and @ark/aot precompiles with the arktype it imports. Install the versions released alongside your arktype so your project doesn't load two copies of it.

arkregex also has an ./internal entrypoint like arktype's, and every package above has ./internal/*.ts deep imports. None of them are semver-stable.