Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>moon_zod Schema GeneratorNew to Visual Studio Code? Get it now.
moon_zod Schema Generator

moon_zod Schema Generator

李家成

| (0) | Free
Generate moon_zod schema from any JSON file with one click — Copy ready-to-use @moon_zod code
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

vscode-moon-zod-schema

Generate moon_zod schema from any JSON file with one click — copy ready-to-use @moon_zod code to your clipboard.

Features

  • CodeLens button — opens automatically when editing .json files
  • Context menu — right-click any JSON file and select "moon_zod: Copy Schema from Current File"
  • JSON Schema import — convert existing JSON Schema to moon_zod code via --from-json-schema
  • Powered by Betterlol/moon_zod — delegates schema inference and code generation to the real moon_zod library, so the output stays in sync with library updates

Requirements

  • MoonBit toolchain (moon CLI in PATH)
  • VS Code ^1.85.0

Installation

From VSIX

vsce package
code --install-extension vscode-moon-zod-schema-*.vsix

From Marketplace (once published)

Search "moon_zod Schema Generator" in the Extensions pane.

Usage

  1. Open any .json file in VS Code
  2. Click "Copy moon_zod Schema" in the editor top bar, or right-click → "moon_zod: Copy Schema from Current File"
  3. The generated @moon_zod code is copied to your clipboard

The schema is generated via the bundled MoonBit package at gen/, which delegates to Betterlol/moon_zod for inference and code generation.

How It Works

The extension bundles a small MoonBit CLI tool (gen/) that runs under the hood:

moon run gen -- --verbose '<json>'

The output is parsed for ── Generated moon_zod Schema ──, and everything after that marker is copied to the clipboard.

The gen/ package uses:

  • @moon_zod.json_infer_schema — infer a schema from a raw JSON value
  • @moon_zod.schema_to_moon_zod_code — render the schema as MoonBit source code
  • @moon_zod.json_schema_to_moon_zod — convert JSON Schema to moon_zod code

You can also use the CLI standalone:

moon run gen -- '{"name": "Alice"}'
moon run gen -- --from-json-schema '{"type": "object", "properties": {...}}'
moon run gen -- --verbose '{"name": "Alice"}'

Development

# Install dependencies
moon add Betterlol/moon_zod

# Build & test
moon run gen -- '{"hello": "world"}'

# Package
npm install -g @vscode/vsce
vsce package

License

Apache-2.0

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft