# sass-formatter

> TypeScript Sass formatter

Latest version **0.8.0** (published 2025-08-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install sass-formatter
pnpm add sass-formatter
yarn add sass-formatter
bun add sass-formatter
```

Provides the command `sass-formatter`.

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.0 |
| Published | 2025-08-29 |
| First published | 2019-09-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 68.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Syler |
| Maintainers | the_real_syler |
| Keywords | sass, formatter, typescript |

## Links

- npm: https://www.npmjs.com/package/sass-formatter
- Repository: https://github.com/TheRealSyler/sass-formatter
- Homepage: https://github.com/TheRealSyler/sass-formatter#readme
- Issues: https://github.com/TheRealSyler/sass-formatter/issues
- npm.io page: https://npm.io/package/sass-formatter

## Dependencies (1)

- [suf-log](https://npm.io/package/suf-log.md) ^2.5.3

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.8.0 (latest) — 2025-08-29
- 0.7.9 — 2024-01-27
- 0.7.8 — 2023-09-09
- 0.7.7 — 2023-08-03
- 0.7.6 — 2023-02-11
- 0.7.5 — 2022-07-03
- 0.7.4 — 2022-05-28
- 0.7.3 — 2022-02-12
- 0.7.2 — 2021-06-25
- 0.7.1 — 2021-02-20
- 0.7.0 — 2021-01-26
- 0.6.0 — 2021-01-25
- 0.5.2 — 2020-11-13
- 0.5.1 — 2020-10-17
- 0.5.0 — 2020-10-04
- … 28 more at https://npm.io/package/sass-formatter/versions

## README

### Sass Formatter

<span id="BADGE_GENERATION_MARKER_0"></span>
[![Custom](https://jestjs.io/img/jest-badge.svg)](https://github.com/facebook/jest) [![Custom](https://www.codefactor.io/repository/github/therealsyler/sass-formatter/badge)](https://www.codefactor.io/repository/github/therealsyler/sass-formatter) [![Custom](https://github.com/TheRealSyler/sass-formatter/actions/workflows/main.yml/badge.svg)](https://github.com/TheRealSyler/sass-formatter/actions/workflows/main.yml) [![codecov](https://codecov.io/gh/TheRealSyler/sass-formatter/branch/master/graph/badge.svg)](https://codecov.io/gh/TheRealSyler/sass-formatter) [![npmV](https://img.shields.io/npm/v/sass-formatter?color=green)](https://www.npmjs.com/package/sass-formatter) [![min](https://img.shields.io/bundlephobia/min/sass-formatter)](https://bundlephobia.com/result?p=sass-formatter) [![install](https://badgen.net/packagephobia/install/sass-formatter)](https://packagephobia.now.sh/result?p=sass-formatter) [![githubLastCommit](https://img.shields.io/github/last-commit/TheRealSyler/sass-formatter)](https://github.com/TheRealSyler/sass-formatter)
<span id="BADGE_GENERATION_MARKER_1"></span>

### Website [sass-formatter.syler.de](https://sass-formatter.syler.de/)

## Used in

- [Vscode sass extension](https://github.com/TheRealSyler/vscode-sass-indented)

## Usage

```typescript
import { SassFormatter } from 'sass-formatter';

const result = SassFormatter.Format(
  `
    span
      color: none

      @for $i from 0 through 2
         
          &:nth-child(#{$i})
              color: none
          @each $author in $list
              .photo-#{$author}
                background: image-url("avatars/#{$author}.png") no-repeat

    @while $types > 0
          .while-#{$types}
 width: $type-width + $types`
);
```

#### Result

```sass
span
  color: none

  @for $i from 0 through 2

    &:nth-child(#{$i})
      color: none
      @each $author in $list
        .photo-#{$author}
          background: image-url("avatars/#{$author}.png") no-repeat

    @while $types > 0
      .while-#{$types}
        width: $type-width + $types
```

## CLI

Sass Formatter includes a command-line interface for formatting directly from editors or CI.

```bash
# show help
$ sass-formatter --help

# rewrite files in place
$ sass-formatter -w src/styles/main.scss

# check formatting without writing
$ sass-formatter -ch "src/**/*.sass"

# use custom config file
$ sass-formatter -c ./my-config.json src/**/*.scss
```

Options summary:

```
-w, --write                 Rewrite the file after formatting
-ch, --check                Check if the file is formatted
-d, --default-config        Show default config
-c, --config <Path>         Use custom config file (JSON)
-h, --help                  Print this help
```

Notes:

- By default loads `.sassformatterrc.json` from PWD.
- Config is merged with defaults; missing keys are taken from defaults.
- Unknown keys trigger warnings; invalid values trigger exit code 1.
- Supports formatting: `sass`, `scss`, `css`, `less`.

<span id="DOC_GENERATION_MARKER_0"></span>

# Docs

- **[config](#config)**

  - [SassFormatterConfig](#sassformatterconfig)
  - [defaultSassFormatterConfig](#defaultsassformatterconfig)

### config

##### SassFormatterConfig

```ts
interface SassFormatterConfig {
    /**Enable debug messages */
    debug: boolean;
    /**delete rows that are empty. */
    deleteEmptyRows: boolean;
    /**@deprecated*/
    deleteWhitespace: boolean;
    /**Convert css or scss to sass */
    convert: boolean;
    /**set the space after the colon of a property to one.*/
    setPropertySpace: boolean;
    tabSize: number;
    /**insert spaces or tabs. */
    insertSpaces: boolean;
    /**Defaults to LF*/
    lineEnding: 'LF' | 'CRLF';
}
```

##### defaultSassFormatterConfig

```ts
const defaultSassFormatterConfig: SassFormatterConfig;
```

_Generated with_ **[suf-cli](https://www.npmjs.com/package/suf-cli)**
<span id="DOC_GENERATION_MARKER_1"></span>

### .sassformatterrc.json

```json
{
  "insertSpaces": true,
  "tabSize": 2,
  "convert": true,
  "debug": false,
  "deleteEmptyRows": true,
  "deleteWhitespace": true,
  "setPropertySpace": true,
  "lineEnding": "LF"
}
```

## Install

```bash
# install locally (recommended)
npm install --save-dev sass-formatter

# or globally
# npm install -g sass-formatter

# or run without install
# npx sass-formatter --help
```

## License

<span id="LICENSE_GENERATION_MARKER_0"></span>
Copyright (c) 2019 Leonard Grosoli Licensed under the MIT license.
<span id="LICENSE_GENERATION_MARKER_1"></span>

---
_Source: https://npm.io/package/sass-formatter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
