Registry / storage / kiwi-schema

kiwi-schema

JSON →
library0.5.0jsnpmunverified

Kiwi Schema is a schema-based binary serialization format for encoding hierarchical data efficiently. Version 0.5.0 is current, with no established release cadence. It compiles schemas to optimized JavaScript code for encoding and decoding, aiming to be smaller and faster than JSON for structured data. Unlike Protocol Buffers or FlatBuffers, Kiwi is focused on tree-shaped data and JavaScript-first usage.

npm install kiwi-schema
INSTALL
IMPORT
SIG · KIWI-SCHEMA
K
kiwi-schema
storagejavascriptv0.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

KiwiSchema
import { KiwiSchema } from 'kiwi-schema'
const kiwi = require('kiwi-schema')
ESM-only from v0.5.0. Use named import.
compile
import { compile } from 'kiwi-schema'
import compile from 'kiwi-schema/compile'
compile is a named export from the main entry.
decode
import { decode } from 'kiwi-schema'
import { decode } from 'kiwi-schema/decode'
All public functions are top-level named exports.

Shows basic schema compilation, encoding an object to binary, and decoding back.

import { KiwiSchema, compile, encode, decode } from 'kiwi-schema'; const schemaText = ` type User { name: string age: int32 email: string } `; const compiled = compile(schemaText); const user = { name: 'Alice', age: 30, email: 'alice@example.com' }; const buffer = encode(compiled, 'User', user); const decoded = decode(compiled, 'User', buffer); console.log(decoded); // { name: 'Alice', age: 30, email: 'alice@example.com' }
Debug
Known issues
deprecatedThe package is in early development (v0.x); API may break without major version bump.
fix
Pin to exact version and test upgrades.
affects: <1.0.0
gotchaKiwi uses a custom schema definition language; it does not support JSON Schema or similar.
fix
Learn the Kiwi schema grammar as documented.
affects: >=0.1.0
gotchaInteger types like int32 are 32-bit signed; overflow may cause data corruption.
fix
Use int64 for large numbers, or ensure values fit within ranges.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Unknown type 'string'
Schema syntax error: type names are lowercase, but Kiwi uses 'string' as a primitive; this error may occur if the schema parser encounters an unexpected token.
fix
Ensure the schema is valid per Kiwi grammar: use 'string', 'int32', 'int64', 'float64', etc., with correct syntax.
TypeError: (intermediate value).compile is not a function
Importing the package incorrectly, perhaps using default import instead of named.
fix
Use `import { compile } from 'kiwi-schema'` (ESM named import).
Error: Version mismatch: decoder expects schema version X but buffer indicates version Y
Buffer was encoded with a different schema version than the one used to decode.
fix
Ensure the same compiled schema object is used for both encode and decode.
Upgrade
Version history
0.5.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
74 hits · last 30 days
node
71
Amazon
1
OpenAI (training)
1
Resources
kiwi-schema — npm install kiwi-schema · libregistry