https://github.com/sindresorhus/indent-string
  
  
    Indent each line in a string 
    https://github.com/sindresorhus/indent-string
  
        Last synced: 6 months ago 
        JSON representation
    
Indent each line in a string
- Host: GitHub
 - URL: https://github.com/sindresorhus/indent-string
 - Owner: sindresorhus
 - License: mit
 - Created: 2014-06-06T20:16:03.000Z (over 11 years ago)
 - Default Branch: main
 - Last Pushed: 2022-06-05T07:44:39.000Z (over 3 years ago)
 - Last Synced: 2025-05-03T06:28:38.216Z (6 months ago)
 - Language: JavaScript
 - Size: 32.2 KB
 - Stars: 113
 - Watchers: 6
 - Forks: 17
 - Open Issues: 0
 - 
            Metadata Files:
            
- Readme: readme.md
 - Funding: .github/funding.yml
 - License: license
 - Security: .github/security.md
 
 
Awesome Lists containing this project
- awesome-nodejs - indent-string - Indent each line in a string. (Repository / Text/String)
 - awesome-github-star - indent-string
 - awesome-nodejs - indent-string - Indent each line in a string. (Packages / Text)
 - awesome-cli - indent-string - Indent each line in a string. (Helpful)
 - awesome-node - indent-string - Indent each line in a string. (Packages / Text)
 - awesome-nodejs-cn - indent-string - 缩进字符串中的每一行. (目录 / 文本处理)
 - awesome-nodejs - indent-string - Indent each line in a string - ★ 57 (Text)
 - awesome-nodejs-cn - indent-string - **star:113** 缩进字符串中的每一行 (包 / 文本)
 - awesome-nodejs-cn - indent-string - 缩进字符串中的每一行. (包 / 文本)
 - fucking-awesome-nodejs - indent-string - Indent each line in a string. (Packages / Text)
 - fucking-awesome-nodejs - indent-string - Indent each line in a string. (Packages / Text)
 
README
          # indent-string
> Indent each line in a string
## Install
```
$ npm install indent-string
```
## Usage
```js
import indentString from 'indent-string';
indentString('Unicorns\nRainbows', 4);
//=> '    Unicorns\n    Rainbows'
indentString('Unicorns\nRainbows', 4, {indent: '♥'});
//=> '♥♥♥♥Unicorns\n♥♥♥♥Rainbows'
```
## API
### indentString(string, count?, options?)
#### string
Type: `string`
The string to indent.
#### count
Type: `number`\
Default: `1`
How many times you want `options.indent` repeated.
#### options
Type: `object`
##### indent
Type: `string`\
Default: `' '`
The string to use for the indent.
##### includeEmptyLines
Type: `boolean`\
Default: `false`
Also indent empty lines.
## Related
- [indent-string-cli](https://github.com/sindresorhus/indent-string-cli) - CLI for this module
- [strip-indent](https://github.com/sindresorhus/strip-indent) - Strip leading whitespace from every line in a string
- [redent](https://github.com/sindresorhus/redent) - Strip redundant indentation and indent the string
---
	
		Get professional support for this package with a Tidelift subscription
	
	
	
		Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.