PX → REM Converter
A VSCode extension that automatically converts all px values to rem in a file.
- Supports:
javascript , typescript , css , scss , vue , html .
- Works via command, keyboard shortcut, or Code Actions on Save.
- Conversion base is configurable (default: 16px = 1rem).
Installation
- Download the extension or clone the repository.
- Open VSCode in the project folder.
- Press
F5 to run the extension in development mode.
- Optionally, package or publish it on the Marketplace.
Usage
Command
- Shortcut:
Alt+D in a supported file.
- Command Palette:
Cmd+Shift+P → Convert PX to REM (whole file) .
Code Actions on Save
To automatically convert all px values to rem when saving, add the following line directly in your settings.json:
"editor.codeActionsOnSave.source.fixAll.pxToRemFile": true
Conversion Base
You can customize the conversion base by adding this line directly in your settings.json:
"pxToRemFile.base": 16
- Example:
"pxToRemFile.base": 20 → 20px = 1rem.
- Default: 16 → 16px = 1rem.
Examples
PX Value |
Conversion Base |
REM Result |
32px |
16 |
2rem |
40px |
20 |
2rem |
24px |
16 |
1.5rem |
License
MIT
| |