SVG ViewBox Number Parser
Parse an SVG viewBox with explicit nonnegative width/height; zero dimensions are retained as nonrenderable, not a valid aspect-ratio divisor.
Description
Parse an SVG viewBox with explicit nonnegative width/height; zero dimensions are retained as nonrenderable, not a valid aspect-ratio divisor.
A viewBox token describes a minimum point and nonnegative width/height. Zero dimensions can be parsed while being nonrenderable.
When to use this tool
Parse an SVG viewBox with explicit nonnegative width/height; zero dimensions are retained as nonrenderable, not a valid aspect-ratio divisor.
- Prepare the supplied value fields for this operation.
- Compare the complete example with the representation used by your own input before carrying the result into another step.
How to use the tool and how it works
- Enter value. Use the exact text syntax, units and index conventions explained below.
- Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
- Read result.minX, result.minY, result.width, result.height, result.renderable. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.
Parse exactly four finite SVG numbers. Require width and height nonnegative; return minX/minY and dimensions, with renderable true only when both extents exceed zero.1
| Input field | Meaning and representation | Accepted input |
|---|---|---|
| value | value. | Text; at most 8,192 UTF-16 code units, subject to the grammar above |
| Output field | Interpretation |
|---|---|
| result | Object containing the named outputs below. |
| result.minX | The min x value under the stated formula or text convention. |
| result.minY | The min y value under the stated formula or text convention. |
| result.width | The width value under the stated formula or text convention. |
| result.height | The height value under the stated formula or text convention. |
| result.renderable | Flag for renderable under the exact condition described above. |
{
"input": {
"value": "0 0 10 20"
},
"output": {
"result": {
"minX": 0,
"minY": 0,
"width": 10,
"height": 20,
"renderable": true
}
}
} Limitations and assumptions
- No viewport, aspect ratio or rendered document is inspected. The flag addresses only positive dimensions under this local check.
- Point pairs use [x,y], rectangles and viewBox use [x,y,width,height], and all coordinate units must be consistent. This tool does not read, render or modify an SVG document.
- Every declared top-level field is required and unexpected fields are rejected. Numeric inputs must be finite; ordinary text fields are bounded to 8,192 UTF-16 code units, with tighter operation-specific limits where stated.
- String lists have at most 128 entries of at most 128 code units; matrices have at most 128 rows and columns. Larger numeric lists and parsed JSON have separate bounded budgets. Nonfinite results and excessively large serialized outputs are rejected.
- Indexes are zero-based and spans have an exclusive end unless explicitly stated otherwise. A valid false, null or empty-list result is distinct from malformed input.
Alternative or Complementary methods
Use a full SVG parser or rendering engine when the task includes commands and CSS values outside the documented branch. Compare coordinates and transforms under the same units and viewport convention.
References
Similar or alternative tools
- SVG Stroke Dasharray Number Parser
Parse the unitless finite-number SVG stroke-dasharray branch or none; lengths with units and percentages require a separate context.
- SVG Move Line Command Parser
Parse the bounded SVG M/m/L/l number-pair branch with implicit lineto after moveto; reject curves, closepath and incomplete commands.