◈Free
SVG viewBox fit calculator
Compute contain/cover scale and offsets for a rectangle.
Compute contain/cover scale and offsets for a rectangle. Compare source and target rectangles to calculate contain or cover scaling and centered offsets. Results include scale, rendered width and height, and x/y placement.
How to use
- Enter your text, values, or image.
- Adjust the options and run the tool.
- Copy or download your result.
Worked example
Example input
Source width: 100 Source height: 100 Target width: 200 Target height: 100 Fit: contain
Example result
{
"scale": 1,
"width": 100,
"height": 100,
"x": 50,
"y": 0
}Limitations and details
Only proportional centered fitting is calculated; the tool does not modify SVG markup or account for stroke bounds and internal padding.
Inputs and options
- Source width
- Number · Minimum: 0.001 · Maximum: 100000
- Source height
- Number · Minimum: 0.001 · Maximum: 100000
- Target width
- Number · Minimum: 0.001 · Maximum: 100000
- Target height
- Number · Minimum: 0.001 · Maximum: 100000
- Fit
- Contain / Cover
Frequently asked questions
Is this tool free and private?
Yes. All 300 tools are free in this phase. Processing happens in your browser; your input and files are not sent to our servers.