---
title: "LinkML to JSON Schema"
description: "Turn a LinkML class into a JSON Schema from your AI assistant."
slug: "linkml-to-jsonschema"
type: recipe
locale: en-US
canonical: "https://www.coremodels.io/recipe/converter/linkml-to-jsonschema"
updatedAt: "2026-12-02T22:12:37+00:00"
last_updated: "2026-12-02T22:12:37+00:00"
---

# LinkML to JSON Schema

Turn a LinkML class into a JSON Schema from your AI assistant.

You have a LinkML schema. You need a JSON Schema. Use this when LinkML is your source and another tool only reads JSON Schema. The output keeps the field names, the allowed values and the required fields. The page shows the recorded output and lists what did not carry over.

- Tool: `transform_schema` on https://go.coremodels.io/mcp (read-only, sign-in required)
- From: LinkML
- To: JSON Schema
- Recorded: 2026-12-03

## What you get

A JSON Schema with seven properties. Six are required and `status` keeps its four allowed values. This is the answer CoreModels gave on 3 December 2026 for the file below.

`order.schema.json`

```json
{
  "type": "object",
  "properties": {
    "order_id": {
      "type": "string"
    },
    "customer_id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "placed",
        "shipped",
        "delivered",
        "returned"
      ]
    },
    "total_amount": {
      "type": "number"
    },
    "currency": {
      "type": "string"
    },
    "placed_at": {
      "type": "string"
    },
    "discount_code": {
      "type": "string"
    }
  },
  "required": [
    "order_id",
    "customer_id",
    "status",
    "total_amount",
    "currency",
    "placed_at"
  ]
}
```

## What you need

- A CoreModels account with one project. Every plan starts with a 14-day free trial; a card is required to start.
- The tool uses the project only to check your access. It writes nothing.
- An assistant that speaks MCP, such as Claude Code, Claude Desktop or Cursor.
- A LinkML file with one flat record.

## Run it

### 1. Connect your assistant

In Claude Code, run this command. Then sign in when it asks.

```bash
claude mcp add --transport http coremodels https://go.coremodels.io/mcp
```

Cursor, Claude Desktop and other clients: [connect guide](/mcp-server).

### 2. Save the file as `order.linkml.yaml`

Use your own file, or start with this one.

`order.linkml.yaml`

```yaml
id: https://example.org/shop
name: shop
title: Shop Order
description: Flat purchase-order model for a small shop.
license: https://creativecommons.org/publicdomain/zero/1.0/
version: 0.1.0

prefixes:
  shop: https://example.org/shop/
  linkml: https://w3id.org/linkml/
  xsd: http://www.w3.org/2001/XMLSchema#

default_prefix: shop
default_range: string

imports:
  - linkml:types

classes:

  Order:
    description: A purchase order placed by a customer.
    attributes:
      order_id:
        description: Order number printed on the receipt.
        identifier: true
        required: true
        range: string
      customer_id:
        description: The customer who placed the order.
        required: true
        range: string
      status:
        description: Where the order is now.
        required: true
        range: OrderStatus
      total_amount:
        description: Order total, tax included.
        required: true
        range: decimal
      currency:
        description: ISO 4217 currency code.
        required: true
        range: string
        pattern: "^[A-Z]{3}$"
      placed_at:
        description: When the customer placed the order.
        required: true
        range: datetime
      discount_code:
        description: Code used at checkout, if any.
        range: string

enums:

  OrderStatus:
    description: Where the order is now.
    permissible_values:
      placed:
        description: Order has been placed.
      shipped:
        description: Order has been shipped.
      delivered:
        description: Order has been delivered.
      returned:
        description: Order has been returned.
```

### 3. Ask for the conversion

```text
Use the CoreModels transform_schema tool to convert order.linkml.yaml from linkml to jsonschema. Pass the whole file as sourceSchema and again as targetHintSchema. Use any project from list_projects. Save the result as order.schema.json, then list every entry in lossiness.
```

Your assistant calls `transform_schema` with these arguments. The file goes in twice: once as the source, once as the hint the mapping matches against. Without the hint the tool refuses the call.

`transform_schema`

```json
{
  "graphProjectId": "<your project id>",
  "sourceFormat": "linkml",
  "sourceSchema": "<contents of order.linkml.yaml>",
  "targetFormat": "jsonschema",
  "targetHintFormat": "linkml",
  "targetHintSchema": "<contents of order.linkml.yaml>"
}
```

## What did not carry over

- We tested one flat record. Nested records and lists are not tested on this page.

The tool returned an empty list of losses for this run. We compared the two files by hand and found these:

- Descriptions. Each field has a description in the input. The output has none.
- The time type. `placed_at` is a date and time in the input and a plain string in the output.
- The identifier. The input marks `order_id` as the key. The output does not.
- Text patterns. The input limits `currency` to three capital letters. The output does not.
- The namespace, package or schema id of the input file.
- The decimal type. `total_amount` is a decimal in the input and a `number` in the output.

Compare your own files too. A different file can lose other things.

## Check it yourself

Validate the file against its own JSON Schema dialect.

```bash
pip install check-jsonschema
check-jsonschema --check-metaschema order.schema.json
```

## Same file, other formats

- [LinkML to Synapse JSON Schema](/recipe/converter/linkml-to-synapse)
- [LinkML to Protobuf](/recipe/converter/linkml-to-protobuf)

[Start building](https://www.coremodels.io/start)

14-day free trial. Builder $49/mo after the trial. Cancel any time.

## Sitemap

- [Sitemap in markdown](https://www.coremodels.io/sitemap.md)
