Cookies This site keeps only what it needs to work. There is no analytics and no advertising on it today, and nothing here follows you to other sites. Read the privacy policy

Choose what to allow
+92 312 8299940Free Quote
EN – Language: English
Free tool, no account needed

Less to CSS, SCSS to CSS
A Converter for Any Preprocessor File

Transform LESS into CSS, or transform SCSS into CSS using this online tool. This tool parses the nested rules, variables, and mixins from either LESS or SCSS files, then creates the flat CSS file that is read by browsers. So, you can transform SCSS to CSS, LESS to CSS, or convert plain CSS back to either LESS or SCSS. All operations are done within your browser, and no data is uploaded to our servers.

  • FreePrice
  • Both waysDirections
  • NoneSign-up
  • NoneUploads

CSS Preprocessor Converter

Turn SCSS, Less or Stylus into plain CSS, or take a flat stylesheet back to nesting

Ready. Paste a stylesheet, or press one of the sample buttons.

Your browser does all of the work here, in this tab. We upload nothing, store nothing and log nothing.

Run it on a test page before the live one

Keep a copy of your original code and try the result on a test page before you replace the live file. No automatic tool can see every way your site uses its code.

Add a link to this tool on your own site

Copy the code below and drop it into your page. It places a link to this free tool.

The short version

What A CSS Preprocessor Converter Does

This is how a CSS preprocessor works, by converting the nested rules into flattened rules, replacing the variable names with their actual values, and then generating standard CSS that the web browser will be able to parse.

Three results are generated by a single copy/paste operation. The first result is the compiled CSS, which can be copied and pasted into a file. The second result is a list of variables and mixins that were identified, along with their respective values. The third result is a notes section that finds all decisions made independently by the compiler.

That last panel has a lot more weight than it looks. An unsaid thought inside of a CSS file translates into a damaged design when you look at it two views down. So, the converter shows each of its thoughts next to the output as opposed to hiding them.

This tool can convert your standard CSS code into its original preprocessor format. Standard CSS files are very difficult to maintain organized so this tool will allow you to convert standard CSS into either SCSS or LESS and pull out all the common value references to create variables for them. This tool needs no installation on your part nor does it need you to upload any files.

How A Preprocessor Compiles To CSS

The first step of each conversion is for the reader to convert the source into a list of rules that have a selector, a block, and a depth. In the second pass, the reader connects the nested selectors to their parent. After both passes, the writer then outputs the flat rules in order.

Diagram of the CSS preprocessor converter: nested SCSS with a mixin, the flattened CSS, and the notes panel
Nesting goes in, flat rules come out.

The process of joining selectors adheres to the selector rules that the browser utilizes. One level of nesting will create a descendant selector. When a rule has an ampersand, it will keep its parent connected to it. This allows for building a hover state and a modifier class.

CSS preprocessor converter turning SCSS into flat CSS, with the mixin inlined and the nested rule flattened
Nesting and a mixin on the left, flat CSS on the right.

Variables are the second job. Because SCSS and Less both let a name stand for a value, the compiler looks up every name it meets and writes the value in its place. Sass variables start with a dollar sign, and Less variables start with an at sign, so the reader tells them apart by the first character.

The author doesn’t use the browser’s APIs, and he doesn’t use the network. This allows him to continue to work with his page when he isn’t connected to the internet. Also, he can write code in files that he doesn’t want to upload to a public compiler (e.g., a stylesheet for an unreleased product).

SCSS, Less and Stylus Side By Side

The three languages have the same meaning, but use different punctuation. The compiler will read each of the three languages, and then generate only one output.

SCSS keeps the braces and semicolons from CSS so it has an added feature set to CSS. Less does this as well and gives the option to use a partial mixin call without using parentheses. Stylus removes all braces, semicolons and sometimes colons and relies upon indentations.

Because the differences are small, one page can read all three. The reader decides which language it has by looking at the file: a dollar sign points at SCSS, an at sign in front of a name points at Less, and a missing brace points at Stylus. When the source is ambiguous, the page says so in the notes panel rather than guessing.

Whichever way you do it, the results come out the same. The browser will view only one large stylesheet; but you will be able to continue writing the source code using the same programming language as your team members.

Why The Selector Join Is The Hard Part

The most nesting is incorrect if you are using a compiler that combines both selectors by adding a space between them. Since a rule nested within another rule is considered to be a descendant of that rule only if there is no ampersand before the second selector, readers must keep track of the first selector for each level as they move downward.

The full selector that each block prints is maintained. The initial rule at the top of the CSS file contains its own selector. The subsequent rules inside the initial rule inherit the initial rule’s selector and append their own, separated by a space. The use of an ampersand completely removes the space, allowing for attachment of the hover state of a parent to the child without a separation.

The order of the printed rules is the third case. Because a later rule of equal weight wins, the writer keeps the source order at every level. That way the cascade survives the compile, and a rule you meant to win still wins.

What Compiles Cleanly And What Gets A Note

A compiler builds trust when it defines the limits of what it can do. The notes panel will show you all of the constructs the compiler handled, and may need your attention to make sure they were handled correctly.

CSS preprocessor converter notes: an unresolved variable, an unread import and a guarded mixin that was inlined
The panel lists every decision the compiler made.

Mixins compile as they are defined by both of the compilers in your example. The mixin compiles when its guard expression is a basic comparison. A guarded mixin will then inline the branch that corresponds with the evaluation of the guard expression.

CSS preprocessor converter facts: source read as Less, rules written, size before and after, variables and mixins
What the reader found, counted rather than guessed.

Interpolation is noted more often than any other. When you build a value using a variable within a string, that variable must be available to you at compile-time. If the variable is in the same file, you may work out its value. But if the variable comes from an imported file which does not exist in your current file, the value remains as it originally appeared, and the note indicates the missing variable.

Imports And The Size Count In The Notes

The import itself also gets a note. Since the page doesn’t touch the network, it cannot fetch another file. So, an at-import will stay in the output as a regular CSS import, and the panel will state that the file was not read. This way the output is accurate and not secretly incorrect.

The number next to the output also falls under the same concept. A compile may cause the size of a file to increase or decrease. So, the panel displays how many rules have been created within the stylesheet, the declarations that exist within those rules, and the sizes of the input and output. Thus, if a stylesheet increases in size upon being compiled, it will be readily apparent in the panel as opposed to during deployment.

Video guide

The CSS Preprocessor Converter in Action

This brief video shows each step from start to finish. Choose your language below, and switch on captions if they help.

Step by step

How To Convert Less to CSS, Step by Step

Just four steps, and none of them asks you to sign up.

  • Paste your stylesheet

    After copying the entire contents of the file, insert the content of that file into the first text area. It is acceptable if you have only copied part of the file; a single element with its children will be enough for testing.

  • Pick the direction

    Then select the language you will convert from. If you are converting SCSS to CSS, choose SCSS for your input and CSS for your output. Since the program can read both SCSS and CSS, files with a mixture of these languages will compile.

  • Read the notes panel

    At this point, look at the notes before pasting your output into any location. A variable or function name that was unresolved by the compiler will be much simpler to repair when reviewing in a text editor as opposed to a browser displaying a blank space.

  • Copy the CSS out

    Finally, use the output. The copy button will put the complete stylesheet into your computer’s memory. Once you have copied the stylesheet, you can save it next to the source file and then link it just like any other stylesheet.

Why bother

Why Compile Less to CSS In The Browser

Five reasons this beats the usual ways of getting to plain CSS.

  • No build chain

    That means nothing to install and nothing to set up. A compiler in a project will include a package manager, a script and a configuration file. That would be quite a bit of work for only one stylesheet.

  • Your source never leaves

    The compile runs in the tab you already have open. Therefore a stylesheet under a contract stays on your machine. The converter uploads nothing and logs nothing.

  • Both directions

    Most compilers only can convert to one direction. This page groups the flattened CSS into nested structure, which will help if you have a stylesheet that has no source files and want to clean up.

  • You see the assumptions

    Then there’s the notes panel. When a build tool fails, it only gives you a line number. But here, the converter finds every possible reason why that happened using simple language right beside the result.

  • Nothing to keep running

    Lastly, there is not a watch process. There will be no rebuilding when you make changes and save, nor will there be breakage when you return in a month. This means the CSS preprocessor will sit idle until you need its services.

Rules of thumb

Getting A Clean Compile From Any CSS Preprocessor

Six habits that keep the output close to what you expect.

  • Keep the source whole So paste the file, not a fragment, when a variable is set at the top. Because the reader looks for a name at its definition, a fragment that misses that line gets a note.
  • Match the language to the file Then, verify the orientation of the file that was duplicated. Even though a Less file will compile when read as SCSS, the way ampersands operate is different, which may result in unexpected outcomes.
  • Avoid mixing the two A file containing both a dollar sign and an at-sign variable cannot be processed by either language. So, split the file before pasting into the note panel to prevent the note panel from producing noise.
  • Watch the ampersand The ampersand represents the parent selector. A rule defined within a media query that includes an ampersand will be applied to the parent element outside of the query. In almost all cases this is not what you intend to do. Every CSS preprocessor handles the ampersand in the same manner, so the rule moves across different files.
  • Name your mixins The mixin called with a name that is easily found within the text will be cleanly inlined. So, the mixin names should remain distinct from the variable names, as the search for a candidate will always result in only one possible option.
  • Minify last Compile first and minify after, in that order. Because a minifier strips the comments, running it first throws away the notes that explain the output.
Watch out

Seven Slippery Preprocessor Mistakes

Each of these looks harmless in the source and hurts in the browser.

  • Deep nesting

    Five levels of nesting reads well and compiles to a selector nobody can override. Because each level adds weight to the selector, a later rule with one class loses. So keep nesting to three levels.

  • A duplicate variable

    In a situation where there are two instances of a name within the same scope, the one that occurs later takes precedence. As such, the first part of the document appears to disregard the modification made. The name of the winning instance is displayed in the Notes panel for reference.

  • Units on a zero value

    Zero pixels and zero are the same number in CSS. Because a variable holding a bare zero is easier to reuse, prefer the plain zero and drop the unit.

  • Mixin output nobody checked

    A mixin that uses a vendor prefix will add each of its lines to every rule that references it. As a result, when you use a mixin within a loop, you’ll find that your output grows very quickly. When assessing file sizes, look at the size of the compiled version, not the original version.

  • Interpolation in a selector

    The process of creating a class name based on a variable occurs during the compilation phase, so, the resulting class name becomes part of the generated CSS and cannot be modified at run-time. To create a theme which supports both states, you will need to define two separate real classes. Thus, a CSS preprocessor is not suitable for this task.

  • Importing a partial twice

    Two imports of the same partial write its rules twice. Then the second copy overrides the first, and a fix in one place appears to do nothing.

  • Forgetting the source

    The compiled file is what ships, and it is not what you edit. So keep the source in the repository next to it, or the next change starts from a flat file with no nesting left.

Questions

CSS Preprocessor Questions

Is this CSS preprocessor converter free?

Yes. There is no account, no usage cap and no paid plan. So you compile as many stylesheets as you like.

Does it send my stylesheet anywhere?

No. Because both the writer (you) and the reader are running on your computer, the content doesn’t leave your computer. This means that if you have a contract that needs privacy of your stylesheets, they will remain private.

Can it compile SCSS to CSS?

Yes. Paste the SCSS, pick SCSS as the input and CSS as the output. Then the nesting flattens, the variables resolve and the mixins inline.

Can it compile Less to CSS?

Yes. That is the same page with less selected as the input. Because both of those languages use the same concept of nesting, only the variable punctuation will differ.

Does it read Stylus?

Yes. Stylus removes the braces and semicolons and relies upon indentation. So, if there is no brace for the reader to follow, the reader will use the indentation to work out where to go.

Can it turn CSS back into SCSS?

Yes. Since the same page works on either side, it groups flat rules with common selectors into nested ones and takes repeated values as variables.

Does it run my mixins?

It will inline a mixin that was defined in the file that was imported into the page. A mixin that exists in a file that can’t be read by the page will remain a call and will be noted. So, people reading the page won’t have to wonder.

How are imports handled?

As such, the CSS file is imported into the output as plain CSS and the notes section indicates that the CSS file was not accessed. Since the page doesn’t access the internet, there’s no way to download the extra file.

Does it understand variables?

Yes. The reader can tell the difference between a Sass variable and a Less variable based on the first character of the name; a Sass variable has a dollar sign at the beginning of its name and a Less variable has an at sign. The reader will then write out the value where they would use the variable.

Does it minify the output?

It can. If you choose minify it will remove the comments and the unnecessary spaces. But it is better to compile your code first then minify it; this way you will have enough time to review your notes.

Will the output match my build tool exactly?

It matches on the common features: nesting, variables, mixins, extends and simple guards. A construct your build tool handles with a plugin may get a note here instead.

Does it handle media queries inside a rule?

Yes. As the compiler elevates all nested media queries to the highest possible level of the output (similar to how most preprocessors do), the resulting code maintains the same order of priority as the original source.

Does it support the ampersand?

Yes, when you create a rule using a single ampersand (&), the parent will remain associated with that rule. This allows you to develop states like "hover" or to apply modifiers. The compiled selector reads in the exact same manner as it does in your source code.

Can I paste only part of a file?

Yes, as long as the variables it uses are defined within the section you give. The reader will not be able to find a name defined before the section of code you give, and the note explains why.

Does it write source maps?

No. A source map is just a pointer to the original file through a path that is unique to your build. Because this page does not contain a file to point to, any source map generated for this page will be inaccurate.

Does it work offline?

The converter will function on your computer even if there isn’t a signal available, once the page loads. It doesn’t use the network again.

Are my comments kept?

It keeps a block comment by default and can drop it when you choose minify. So a header note survives, and a note that only mattered while editing does not.

How many levels of nesting can it read?

No fixed ceiling exists. Your own file is the practical limit. Deep nesting compiles fine and reads badly. So three levels is a good habit.

Will it cope with a big file?

Yes. Because the task is to process plain text, a single style sheet with thousands of lines can be compiled in less than one second on an ordinary laptop computer.

Does it write CSS custom properties?

It both reads and writes custom properties as ordinary declaration statements. So, custom properties defined in the source code are not altered by the compilation process, and preprocessor variables can contain custom property values.

What about a vendor prefix mixin?

This will write each line of prefix into every single rule that uses this mixin. So you should be looking at the size of the final compiled version of your CSS file, not the size of the source file.

Will it spot errors?

Rather than rejecting the entire file, it will tell you what it couldn’t resolve. That way you have a working document and a list of issues to fix, as opposed to just one problem that stops everything.

Can it compare the two directions?

Yes, if you compile a file to CSS and then use the CSS to re-create the original file, a lossy construct is created. Any content from the first compilation that was lost during the second compilation had no purpose.

Does it touch my clipboard on its own?

No. When you paste, the page will read the contents of your clipboard; when you click "copy," it will write to your clipboard. So, the tool does not read or replace anything unless you interact with it.

Is there a limit on how large the stylesheet can be?

There is no maximum number of styles you can create. Your computer will be the only thing that limits how many styles you can have. The typical style sheet is much smaller than what your computer can handle.

Does it run on phones too, or only on desktops?

Yes. The boxes will be stacked on top of each other, and the copy button is directly below the output. So, if you are not near your computer, you can still easily compile a project using your mobile device.

Keep going

More Developer Tools That Work Well With This One

Four pages the same job usually leads to.

  • CSS minifier

    Then make sure that when you send the compiled version out, you reduce its size. Since minification should occur after compilation so that the comments are still visible, you can use the same method of compiling here and minifying there.

  • CSS color converter

    The first step is to confirm the color you give as a variable. After that, you will be able to view that exact shade in hex format, RGB format and HSL format before applying it to the stylesheet.

  • HTML minifier

    For the markup that pairs with the stylesheet, this drops the comments and the spare whitespace. So both files come out tidier.

  • PX to REM converter

    This means that since a preprocessor variable usually contains a font size, the pixels are converted into rem units. As such, when the code is compiled, the scale of your design will remain constant.

Compile A Stylesheet Now

Paste the SCSS/Less into the box, review the instructions and then download the final flat CSS. All of your work will remain in your web browser, which means that even if you have a contract for a project, the stylesheet will still be yours. It is possible to do the entire process in just one paste.

Prefer Denwix on GoogleReview Denwix on Google