{"id":24629480,"url":"https://github.com/sharpjs/unindent","last_synced_at":"2026-05-07T23:02:20.055Z","repository":{"id":63110699,"uuid":"365567662","full_name":"sharpjs/Unindent","owner":"sharpjs","description":"String unindenter for .NET","archived":false,"fork":false,"pushed_at":"2022-11-13T00:59:48.000Z","size":104,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-25T12:48:38.297Z","etag":null,"topics":["dotnet","string","unindent"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sharpjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-08T16:59:04.000Z","updated_at":"2022-06-12T01:40:54.000Z","dependencies_parsed_at":"2022-11-13T02:45:39.690Z","dependency_job_id":null,"html_url":"https://github.com/sharpjs/Unindent","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FUnindent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FUnindent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FUnindent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FUnindent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sharpjs","download_url":"https://codeload.github.com/sharpjs/Unindent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244554042,"owners_count":20471172,"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":["dotnet","string","unindent"],"created_at":"2025-01-25T06:13:03.455Z","updated_at":"2026-05-07T23:02:19.999Z","avatar_url":"https://github.com/sharpjs.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unindent\n\nA tiny .NET library that removes indentation from multi-line strings.\n\n## Status\n\n[![Build Status](https://github.com/sharpjs/Unindent/workflows/Build/badge.svg)](https://github.com/sharpjs/Unindent/actions)\n[![Package Version](https://img.shields.io/nuget/v/Unindent.svg)](https://www.nuget.org/packages/Unindent)\n[![Package Downloads](https://img.shields.io/nuget/dt/Unindent.svg)](https://www.nuget.org/packages/Unindent)\n\nTest coverage is 100%.\n\nUnindent is available as a [NuGet package](https://www.nuget.org/packages/Unindent).\n\n## Usage\n\nThis package provides an `Unindent` extension method for .NET strings.\n\n```csharp\nvar result = input.Unindent();\n```\n\nThe `Unindent` method returns a string with the content of the input string,\nbut unindented: if all\u003csup\u003e[1](#blank-lines)\u003c/sup\u003e input lines begin with the\nsame amount of space (the *indentation*), that space is removed from the\nreturned string.\n\n*Space* here means any mixture of the space (`U+0020`) and tab (`U+0009`)\ncharacters.  Tabs work like in most text editors:\u003csup\u003e[2](#split-tabs)\u003c/sup\u003e a\ntab advances to the next tab stop.  By default, tab stops are 8 spaces apart.\nThe optional `tabStop` parameter overrides the default.\n\nLines end via any mixture of the carriage return (`U+000D`) and line feed\n(`U+000A`) characters.  Thus Unindent supports `CR+LF` (Windows), `LF`\n(Linux/Unix), and `CR` (classic Mac OS) line endings.\n\n\u003cdetails\u003e\n\u003csummary\u003eClick here for details about some edge cases.\u003c/summary\u003e\n\n- \u003csup\u003e\u003ca id=\"blank-lines\"\u003e1\u003c/a\u003e\u003c/sup\u003e Unindent ignores *blank* lines (those\n  containing only space) when discovering indentation in the input string, but\n  the method still removes indentation from blank lines that have it.  See\n  [this test](https://github.com/sharpjs/Unindent/blob/4bad5c2249c4e4a4a4976ede12799e0d825bca61/Unindent.Tests/StringExtensionsTests.cs#L155-L158)\n  for an example.\n\n- \u003csup\u003e\u003ca id=\"split-tabs\"\u003e2\u003c/a\u003e\u003c/sup\u003e If a tab character jumps past the\n  computed indentation width, that tab is replaced by space characters in order\n  to preserve column alignments present in the input string.  See\n  [this test](https://github.com/sharpjs/Unindent/blob/4bad5c2249c4e4a4a4976ede12799e0d825bca61/Unindent.Tests/StringExtensionsTests.cs#L215)\n  for an example.\n\n- If the input string ends with trailing space, Unindent removes that space.\n  See [this test](https://github.com/sharpjs/Unindent/blob/4bad5c2249c4e4a4a4976ede12799e0d825bca61/Unindent.Tests/StringExtensionsTests.cs#L155-L158)\n  for an example.\n\n\u003c/details\u003e\n\n### Example\n\nGiven this example code:\n\n```csharp\nnamespace Foo\n{\n    public class Bar\n    {\n        const string Query = @\"\n            -- Pretend there is a table called NaturalNumbers\n\n            SELECT TOP 100\n                Output = CASE\n                    WHEN N % 15 = 0 THEN N'Fizz Buzz'\n                    WHEN N %  5 = 0 THEN N'Buzz'\n                    WHEN N %  3 = 0 THEN N'Fizz'\n                    ELSE CONVERT(nvarchar(10), N)\n                END\n            FROM NaturalNumbers; -- 1, 2, 3, ...\n        \";\n    }\n}\n```\n\nThe string constant `Query` is indented by 12 spaces.  To unindent it:\n\n```csharp\nvar query = Query.Unindent();\n```\n\n...which yields:\n\n```\n-- Pretend there is a table called NaturalNumbers\n\nSELECT TOP 100\n    Output = CASE\n        WHEN N % 15 = 0 THEN N'Fizz Buzz'\n        WHEN N %  5 = 0 THEN N'Buzz'\n        WHEN N %  3 = 0 THEN N'Fizz'\n        ELSE CONVERT(nvarchar(10), N)\n    END\nFROM NaturalNumbers; -- 1, 2, 3, ...\n```\n\n\u003c!--\n  Copyright 2022 Jeffrey Sharp\n\n  Permission to use, copy, modify, and distribute this software for any\n  purpose with or without fee is hereby granted, provided that the above\n  copyright notice and this permission notice appear in all copies.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharpjs%2Funindent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsharpjs%2Funindent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharpjs%2Funindent/lists"}