Design
Text fit in a box API
Estimates characters per line, lines, and total character/word capacity for a box from font size, glyph width and line-height. Answers 'How much text fits in a 400x300px box at 16px?', 'Roughly how many words can this box hold?'.
Price$0.04per request
MethodPOST
Route/v1/design/text-fit-box
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
designtypographytext-fitcapacityboxcharacters-per-linelayoutestimate
API URL
Integration docshttps://x402.hexl.dev/v1/design/text-fit-boxExample request
{
"boxWidthPx": 400,
"boxHeightPx": 300,
"fontSizePx": 16
}Example response
{
"boxWidthPx": 400,
"boxHeightPx": 300,
"fontSizePx": 16,
"charWidthPx": 8,
"lineHeightPx": 22.4,
"charactersPerLine": 50,
"lines": 13,
"capacityCharacters": 650,
"capacityWords": 108,
"interpretation": "≈50 chars/line × 13 lines ≈ 650 characters (~108 words)."
}Input schema
{
"type": "object",
"required": [
"boxWidthPx",
"boxHeightPx",
"fontSizePx"
],
"properties": {
"boxWidthPx": {
"type": "number",
"description": "Box width in px",
"examples": [
400
]
},
"boxHeightPx": {
"type": "number",
"description": "Box height in px",
"examples": [
300
]
},
"fontSizePx": {
"type": "number",
"description": "Font size in px",
"examples": [
16
]
},
"avgCharWidthEm": {
"type": "number",
"description": "Average glyph width in em (default 0.5)",
"examples": [
0.5
]
},
"lineHeight": {
"type": "number",
"description": "Line-height multiplier (default 1.4)",
"examples": [
1.4
]
},
"avgWordLength": {
"type": "number",
"description": "Average characters per word (default 5)",
"examples": [
5
]
}
}
}Output schema
{
"type": "object",
"additionalProperties": true
}