Catalog/design-css-unit-convert

Design

CSS unit conversion API

Converts a CSS length between px, rem, em, and pt given a root font size and optional parent size, honoring the 96px=1in / 72pt=1in relationship. Answers 'What is 24px in rem and pt?', 'How many px is 12pt?'.

Price$0.02per request
MethodPOST
Route/v1/design/css-unit-convert
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
designtypographycsspxrememptunit-conversion
API URLhttps://x402.hexl.dev/v1/design/css-unit-convert
Integration docs
Example request
{
  "value": 24,
  "from": "px",
  "rootPx": 16
}
Example response
{
  "input": {
    "value": 24,
    "from": "px"
  },
  "rootPx": 16,
  "parentPx": 16,
  "px": 24,
  "rem": 1.5,
  "em": 1.5,
  "pt": 18,
  "interpretation": "24px = 24px (root 16px, parent 16px)."
}
Input schema
{
  "type": "object",
  "required": [
    "value",
    "from"
  ],
  "properties": {
    "value": {
      "type": "number",
      "description": "Numeric value to convert",
      "examples": [
        24
      ]
    },
    "from": {
      "type": "string",
      "enum": [
        "px",
        "rem",
        "em",
        "pt"
      ],
      "description": "Source unit",
      "examples": [
        "px"
      ]
    },
    "rootPx": {
      "type": "number",
      "description": "Root font size in px (default 16)",
      "examples": [
        16
      ]
    },
    "parentPx": {
      "type": "number",
      "description": "Parent font size in px for em (default = root)",
      "examples": [
        16
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}