Home › All Tools ›

CSS Unit Converter

Use CSS Unit Converter online for free at FreeToolZones — no sign-up, no watermark.

Loading tool...

The CSS Unit Converter translates a length between the units used in stylesheets, so a value designed in pixels can be expressed in rem, a viewport-relative size can be checked in pixels, and a print size in points can be compared with its screen equivalent. CSS offers many ways to say how big something is, and each unit means something different: some are absolute, some scale with the font size, and some scale with the viewport. Converting between them by hand invites arithmetic errors, especially when a project uses a non-standard base font size.

This tool converts through pixels as a common reference, using the base font size and viewport dimensions you provide. Enter a value, choose the source and target units, and the result appears immediately, together with a full table showing the same length in every supported unit. The assumptions behind the conversion are stated beneath the table, so you always know what the numbers depend on.

What Is the CSS Unit Converter?

The CSS Unit Converter is a calculator for seven CSS length units: px for pixels, rem, em, percent of font size, vw for viewport width, vh for viewport height, and pt for points. You enter a numeric value, select the unit it is currently in, and select the unit you want it in. The tool converts the value to pixels first, using conversion factors derived from your settings, then converts from pixels to the target unit. The main display shows the conversion as a single equation, such as 16px equals 1rem.

Three settings control the conversion factors. The base font size, defaulting to 16 pixels, defines the size of 1rem and 1em, and the reference for percentages. The viewport width, defaulting to 1440 pixels, defines the size of 1vw as one hundredth of that width. The viewport height, defaulting to 900 pixels, defines 1vh similarly. Points use a fixed factor: 1 point equals 1.333 pixels, because there are 96 pixels per inch and 72 points per inch in CSS. Results are rounded to four decimal places.

Below the main result, a table lists all seven units with the converted value in each. That table is often more useful than the single conversion, because it lets you compare all representations at once and choose the unit that reads most cleanly for your purpose. A hint beneath the table restates the assumptions, including the current base font size, so the conversion can be verified at a glance.

  • Seven units: px, rem, em, percent, vw, vh, and pt.
  • Base font size setting: used for rem, em, and percent conversions, defaulting to 16 pixels.
  • Viewport settings: width and height inputs used for vw and vh conversions.
  • Full results table: the value in every unit, alongside the headline conversion.
  • Four-decimal rounding: results are rounded to four decimal places for readability.
  • Stated assumptions: the conversion basis is shown beneath every result.

How to Use the CSS Unit Converter

Set the base and viewport sizes to match your project before converting. The same number means different things at different base sizes, and the tool can only be as accurate as its settings.

  1. Enter the value. Type the number to convert in the Value field. The field accepts decimals, with a step of 0.01, and defaults to 16. Non-numeric input produces an error message asking for a numeric value.
  2. Choose the source unit. Use the From dropdown to select the unit the value is currently in: px, rem, em, percent, vw, vh, or pt. The default source is px.
  3. Choose the target unit. Use the To dropdown to select the unit you want. The default target is rem, which is the most common conversion for developers moving from pixel-based designs to scalable typography.
  4. Set the base font size. Enter the base font size in pixels, between 1 and 200, in the Base font size field. The default is 16, which is the usual browser default. If your project sets a different root font size, enter that value instead, because it changes every rem, em, and percent result.
  5. Set the viewport size. Enter the viewport width, between 1 and 10000 pixels, and the viewport height in the same range. The defaults are 1440 by 900. These values matter only for vw and vh conversions, but setting them to your target device size makes those results meaningful.
  6. Convert and read the result. Click Convert, or simply change any input, because the tool recalculates live. The headline display shows the conversion equation, and the table below shows the value in all seven units.
  7. Check the assumptions. Read the hint beneath the table to confirm the base size, the percentage basis, and the point factor used. If the assumptions do not match your project, adjust the settings and convert again.

Key Features of the CSS Unit Converter

The tool is built around transparency: every conversion shows its basis, and every unit is shown together, so the result can be checked rather than trusted blindly.

  • Pixel-based conversion: all units convert through pixels, which is the common reference that makes the factors consistent and easy to verify.
  • Adjustable base size: the base font size is a setting, not a hidden constant, so projects with a 10 pixel or 18 pixel root size get correct results.
  • Adjustable viewport: viewport width and height are settings, so vw and vh conversions reflect the device you are designing for.
  • Complete unit table: seeing all seven values at once prevents the need for repeated conversions when comparing units.
  • Live recalculation: changing any input updates the result immediately, without requiring a button press, although a Convert button is provided.
  • Clear error handling: non-numeric input produces a specific error message instead of a meaningless result.

Practical Use Cases

Unit conversion arises whenever a design, a specification, or an existing stylesheet uses a different unit than the one you want to write. The examples below cover the conversions that come up most often.

Pixels to rem for scalable typography

A design file may specify a heading as 32 pixels, but a scalable stylesheet expresses it in rem so it respects the user’s font size settings. At a 16 pixel base, 32 pixels equals 2rem. Converting the whole type scale this way gives a consistent, accessible typography system.

Rem to pixels for debugging

When inspecting a layout, a developer may need to know how many pixels a rem value actually produces. Converting 1.5rem at a 16 pixel base gives 24 pixels, which can be compared with the measured size in browser developer tools to confirm the base size is as expected.

Viewport units for full-screen sections

A hero section sized in viewport units, such as 50vw wide or 100vh tall, needs checking against real pixel dimensions. Converting at the target viewport size, such as 1440 by 900, shows the actual pixel size the section will occupy on that device.

Points to pixels for print styles

Print stylesheets and PDF specifications often use points, while screen stylesheets use pixels. A 12 point font size converts to 16 pixels at the fixed CSS factor, which helps keep print and screen typography consistent when the same content appears in both.

Percentages for relative sizing

Percentages in this tool are relative to the font size, so 150 percent at a 16 pixel base equals 24 pixels, or 1.5em. Converting percentages to em or rem clarifies the relationship between a percentage-based design and an em-based stylesheet.

Tips and Best Practices

Choosing the right unit matters more than converting accurately between them. These practices help you pick well.

  • Prefer rem for typography: rem scales with the root font size, so it respects user preferences and keeps the type scale consistent across the page. Pixels do not scale in the same way.
  • Use em for component-relative sizing: em scales with the parent font size, which suits padding and spacing inside a component that should grow with its text. Be careful with nesting, because em compounds through ancestors.
  • Use viewport units for viewport-relative layout: vw and vh suit full-screen sections, hero heights, and fluid spacing that should track the window size. Avoid them for body text, where they can produce unreadably small or large sizes.
  • Keep the base size standard unless there is a reason: a 16 pixel root size is the browser default and the least surprising choice. Changing it affects every rem value on the page, so change it deliberately, not casually.
  • Round sensibly in production code: the tool rounds to four decimal places, but a value such as 1.3333rem in a stylesheet is harder to read than 1.33rem. Round to two or three places when the difference is negligible.
  • Verify with developer tools: after converting, check the computed pixel size in the browser. If it differs from the tool result, the base size or viewport size in your project differs from the tool settings.

Limitations

This converter treats em and rem identically, using the single base font size for both. In real CSS, rem is relative to the root element font size, while em is relative to the parent element font size, which may differ, especially in nested components. The tool states its assumption plainly: 1rem and 1em equal the base font size. For nested em calculations, you must work out the parent size yourself and enter it as the base.

Percentages are treated as relative to the font size, which is true for font-size percentages but not for all percentage uses: a percentage width is relative to the containing block width, and a percentage height has its own rules. Viewport conversions use the viewport dimensions you enter, which are fixed numbers, while a real viewport changes as the window resizes. The tool also does not support ch, ex, vmin, vmax, or other CSS units, and it does not account for browser zoom or user font size overrides.

  • Em and rem share one base size; nested em compounding is not modelled.
  • Percentages are font-size relative only; width and height percentages differ.
  • Viewport sizes are fixed inputs; real viewports resize.
  • Seven units only; no ch, ex, vmin, vmax, or other units.

Frequently Asked Questions

What is the difference between em and rem?

Rem is relative to the font size of the root element, so it is consistent everywhere on the page. Em is relative to the font size of the parent element, so it compounds when elements are nested. This tool uses the same base size for both, which matches rem exactly and matches em only when the parent size equals the base size.

Why is 16 pixels the default base size?

Sixteen pixels is the default font size in most browsers when no root size is set, so it is the most common reference for rem conversions. If your project sets a different root font size, enter that value in the base field to get correct results for your project.

How are viewport units calculated?

One vw equals one hundredth of the viewport width, and one vh equals one hundredth of the viewport height, using the dimensions you enter. At the default 1440 pixel width, 1vw equals 14.4 pixels. At the default 900 pixel height, 1vh equals 9 pixels.

Why is 1 point equal to 1.333 pixels?

CSS defines 96 pixels per inch and 72 points per inch, so one point equals 96 divided by 72 pixels, which is 1.333 pixels. This is a fixed CSS definition, independent of the physical screen, and it is the factor this tool uses for point conversions.

Can I convert a value that is already in the target unit?

Yes. If the source and target units are the same, the result equals the input value, and the table still shows the value in the other six units. This is a useful way to see all representations of a known size at once.

Absolute Units and the Myth of the Pixel

Pixels feel absolute, because they are named after the dots on a screen, but in CSS a pixel is a reference unit, not a physical dot. A CSS pixel is defined as a small visual angle, roughly the size of one dot on a typical display viewed at arm’s length, and high-resolution screens map many physical dots to one CSS pixel. That abstraction is what makes the same stylesheet work on a phone, a laptop, and a large monitor without the text becoming microscopic or enormous. It also means that converting points to pixels, or pixels to rem, is a matter of defined ratios, not of measuring a physical screen.

Understanding that abstraction helps when conversions seem surprising. A 12 point font that converts to 16 pixels may look larger or smaller than expected on a particular device, because the device pixel ratio, the browser zoom, and the user’s font size settings all intervene between the CSS value and the physical display. The converter gives the CSS-defined relationship, which is the right basis for writing code, and the browser handles the translation to physical dots. Trust the defined ratios for authoring, and verify the visual result on real devices for confidence.

Related Tools

These tools cover responsive design, typography, and layout sizing that depend on CSS units.

Browse More Tools