Catalog/design-modular-scale

Design

Modular type scale API

Generates a modular typographic scale, size(n) = base x ratio^n, returning px and rem for each step above/below a base size; accepts named musical ratios. Answers 'What font sizes does a 1.25 major-third scale give from 16px?', 'What is the rem value for each step of my type scale?'.

Price$0.04per request
MethodPOST
Route/v1/design/modular-scale
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
designtypographymodular-scaletype-scalefont-sizeratioremgolden-ratio
API URLhttps://x402.hexl.dev/v1/design/modular-scale
Integration docs
Example request
{
  "basePx": 16,
  "ratio": "major-third",
  "stepsUp": 3,
  "stepsDown": 1
}
Example response
{
  "basePx": 16,
  "ratio": 1.25,
  "ratioName": "major-third",
  "stepsUp": 3,
  "stepsDown": 1,
  "scale": [
    {
      "step": -1,
      "px": 12.8,
      "rem": 0.8
    },
    {
      "step": 0,
      "px": 16,
      "rem": 1
    },
    {
      "step": 1,
      "px": 20,
      "rem": 1.25
    },
    {
      "step": 2,
      "px": 25,
      "rem": 1.5625
    },
    {
      "step": 3,
      "px": 31.25,
      "rem": 1.9531
    }
  ],
  "interpretation": "Each step multiplies by 1.25; step 0 = base 16px."
}
Input schema
{
  "type": "object",
  "required": [
    "basePx",
    "ratio"
  ],
  "properties": {
    "basePx": {
      "type": "number",
      "description": "Base font size in px (step 0)",
      "examples": [
        16
      ]
    },
    "ratio": {
      "description": "Numeric ratio (>1) or named interval (minor-second...octave, golden)",
      "examples": [
        "major-third",
        1.25,
        "golden"
      ]
    },
    "stepsUp": {
      "type": "number",
      "description": "Steps above base (default 5)",
      "examples": [
        3
      ]
    },
    "stepsDown": {
      "type": "number",
      "description": "Steps below base (default 2)",
      "examples": [
        1
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}