Strip leading whitespace from each line in a string, removing redundant indentation based on the least-indented line.
strip-indent is a JavaScript library that removes leading whitespace from each line in a string. It solves the problem of cleaning up indented multi-line strings by automatically detecting and stripping redundant indentation based on the least-indented line.
JavaScript and Node.js developers working with multi-line strings, template literals, or code generation who need to clean up indentation in text.
Developers choose strip-indent for its simplicity, reliability, and focused functionality—it handles indentation stripping intelligently without over-engineering, and its `dedent` function is particularly useful for template literals.
Strip leading whitespace from each line in a string
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Intelligently determines the amount to strip by finding the line with the least indentation, ignoring empty lines, as described in the README, eliminating manual calculations.
Includes a `dedent` function that strips surrounding blank lines, making it ideal for cleaning up template literals, as shown in the usage examples for multi-line strings.
Focuses on a single, well-defined task with minimal dependencies, following a minimalist philosophy for consistent performance without unnecessary complexity.
Lacks configuration options for indentation characters or amounts, which can be restrictive for projects needing tailored whitespace handling, such as those with strict formatting standards.
Only handles leading whitespace stripping and basic blank line removal, missing features like trailing whitespace cleanup or more advanced string manipulations offered by related libraries like redent.
For simple indentation removal, manual string methods or regex might suffice, making the external library an unnecessary addition in lightweight or performance-critical applications.