{"id":16483568,"url":"https://github.com/trevorblades/transform-css","last_synced_at":"2025-10-17T14:24:07.266Z","repository":{"id":20023866,"uuid":"23291750","full_name":"trevorblades/transform-css","owner":"trevorblades","description":"🐠 Transforms CSS into beautifully formatted styles ready to use with a preprocessor","archived":false,"fork":false,"pushed_at":"2023-01-13T22:19:18.000Z","size":17229,"stargazers_count":12,"open_issues_count":34,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-14T21:45:54.694Z","etag":null,"topics":["css","less","sass","stylus","transform"],"latest_commit_sha":null,"homepage":"https://transform-css.trevorblades.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trevorblades.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-24T20:22:53.000Z","updated_at":"2023-07-28T20:08:41.000Z","dependencies_parsed_at":"2023-01-14T13:02:18.561Z","dependency_job_id":null,"html_url":"https://github.com/trevorblades/transform-css","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trevorblades%2Ftransform-css","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trevorblades%2Ftransform-css/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trevorblades%2Ftransform-css/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trevorblades%2Ftransform-css/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trevorblades","download_url":"https://codeload.github.com/trevorblades/transform-css/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221812719,"owners_count":16884688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","less","sass","stylus","transform"],"created_at":"2024-10-11T13:14:25.856Z","updated_at":"2025-10-17T14:24:02.205Z","avatar_url":"https://github.com/trevorblades.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Transform CSS\n\n[![Build Status](https://github.com/trevorblades/transform-css/workflows/Node%20CI/badge.svg)](https://github.com/trevorblades/transform-css/actions)\n\nThis library transforms CSS into beautifully formatted styles ready to use with a preprocessor like [LESS](http://lesscss.org/), [SASS](https://sass-lang.com/), or [Stylus](http://stylus-lang.com/). Check out a working example [here](http://transform-css.trevorblades.com)!\n\n## Installation\n\n```shell\n$ npm install transform-css\n```\n\n## Usage\n\n### transformCss(css, options)\n\nTakes a string of CSS as input and returns a string of LESS/SASS. Descendant selectors, subclasses, and pseudo-classes will be nested where it makes sense. Sets of rules will be spaced out for increased readability. Pass `options` as a second argument to customize the format of the returned styles.\n\n```js\nimport transformCss from 'transform-css';\n\nconst css = `\n  #id {\n    width: 420px;\n    color: green;\n  }\n\n  #id .child-class {\n    overflow: hidden;\n  }\n\n  #id .child-class p {\n    margin: 0 1em;\n  }\n\n  #id .child-class p:last-child {\n    margin-bottom: 0;\n  }\n`;\n\ntransformCss(css);\n```\n\nThis will produce the following output:\n\n```less\n#id {\n  width: 420px;\n  color: green;\n\n  .child-class {\n    overflow: hidden;\n\n    p {\n      margin: 0 1em;\n\n      \u0026:last-child {\n        margin-bottom: 0;\n      }\n    }\n  }\n}\n```\n\n## Options\n\n### spaces\n\nBy default, two spaces will be used as indentation for the transformed styles. Use the `spaces` option to change this behaviour.\n\nSpecify a number to control the number of spaces used, or `false` to use tabs.\n\n### omitBracketsAndSemicolons\n\nBy default, `transform-css` will produce code that follows LESS or SCSS syntax, which use brackets to separate selectors from rule declarations and semicolons to separate declarations from one another.\n\n```less\n#container {\n  height: 50px;\n  color: red;\n\n  .header {\n    position: sticky;\n    top: 24px;\n  }\n}\n```\n\nOn the other hand, SASS and Stylus use newlines and tabs to separate stylesheet elements from one another. Set the `omitBracketsAndSemicolons` option to `true` to use this syntax.\n\n```js\ntransformCss(css, {omitBracketsAndSemicolons: true})\n```\n\nTurns into...\n\n```stylus\n#container\n  height: 50px\n  color: red\n\n  .header\n    position: sticky\n    top: 24px\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrevorblades%2Ftransform-css","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrevorblades%2Ftransform-css","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrevorblades%2Ftransform-css/lists"}