Advertisement

About DevCraft

A high-performance CSS unit conversion suite engineered for web designers, frontend developers, and design systems.

Instant Calculations

Lightweight client-side engine with zero network roundtrips for real-time reactivity as you type.

Precision Formatted

Eliminates floating-point anomalies (e.g. 1.6000000000000001) while trimming redundant trailing zeros.

Next.js API Route

A standard HTTP endpoint for programmatic conversions and server-side automation.

Programmatic API: POST /api/convert

Integrate unit conversions into build scripts, IDE extensions, or workflows.

HTTP 200 / 400
Example Request (cURL)
curl -X POST https://devcraft.dev/api/convert \
  -H "Content-Type: application/json" \
  -d '{
    "value": 1.5,
    "from": "rem",
    "to": "px",
    "rootFontSize": 16
  }'
JSON Request Body Payload
{
  "value": 1.5,               // (Required) Number to convert
  "from": "rem",              // (Required) Source unit
  "to": "px",                 // (Required) Target unit
  "rootFontSize": 16,         // (Optional, default: 16) Root font size in px
  "contextFontSize": 16,      // (Optional, default: 16) Parent font size for em
  "viewportWidth": 1440,      // (Optional, default: 1440) Viewport width in px
  "viewportHeight": 900,      // (Optional, default: 900) Viewport height in px
  "referenceValue": 1000,     // (Optional, default: 1000) Base context for %
  "precision": 4              // (Optional, default: 4) Max decimal places
}
JSON Success Response (200 OK)
{
  "input": {
    "value": 1.5,
    "unit": "rem"
  },
  "result": {
    "value": 24,
    "unit": "px",
    "formatted": "24"
  },
  "explanation": "1.5rem × 16px (root font size) = 24px"
}