{"id":13697944,"url":"https://github.com/slomkowski/nginx-config-formatter","last_synced_at":"2025-05-16T12:02:19.202Z","repository":{"id":44456524,"uuid":"60739977","full_name":"slomkowski/nginx-config-formatter","owner":"slomkowski","description":"nginx config file formatter/beautifier written in Python with no additional dependencies.","archived":false,"fork":false,"pushed_at":"2024-10-11T15:32:51.000Z","size":97,"stargazers_count":390,"open_issues_count":6,"forks_count":66,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-14T04:58:58.949Z","etag":null,"topics":["beautifier","formatter","formatting","nginx","nginx-configuration"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slomkowski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-09T00:28:21.000Z","updated_at":"2025-03-29T08:49:57.000Z","dependencies_parsed_at":"2024-12-06T07:02:58.353Z","dependency_job_id":"aa509a39-b896-4400-8fe9-2210648f4c09","html_url":"https://github.com/slomkowski/nginx-config-formatter","commit_stats":{"total_commits":39,"total_committers":7,"mean_commits":5.571428571428571,"dds":0.3076923076923077,"last_synced_commit":"485617f8fc86a20fe7ed82b7bb0fbe0d00facb16"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slomkowski%2Fnginx-config-formatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slomkowski%2Fnginx-config-formatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slomkowski%2Fnginx-config-formatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slomkowski%2Fnginx-config-formatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slomkowski","download_url":"https://codeload.github.com/slomkowski/nginx-config-formatter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254527074,"owners_count":22085918,"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":["beautifier","formatter","formatting","nginx","nginx-configuration"],"created_at":"2024-08-02T18:01:06.241Z","updated_at":"2025-05-16T12:02:19.136Z","avatar_url":"https://github.com/slomkowski.png","language":"Python","funding_links":[],"categories":["Third Modules","Tools","Python"],"sub_categories":["C Modules","Lua Modules"],"readme":"# *nginx* config file formatter/beautifier\n\n*nginx* config file formatter/beautifier written in Python with no additional dependencies. It can be used as library or standalone script. It formats *nginx* configuration files in consistent way, described below:\n\n* All lines are indented in uniform manner, with 4 spaces per level. Number of spaces is customizable.\n* Neighbouring empty lines are collapsed to at most two empty lines.\n* Curly braces placement follows Java convention.\n* Whitespaces are collapsed, except in comments and quotation marks.\n\n\n## Installation\n\nPython 3.4 or later is needed to run this program. The easiest way is to download package from PyPI:\n\n```bash\npip3 install nginxfmt\n```\n\n\n### Manual installation\n\nThe simplest form of installation would be copying `nginxfmt.py` to\nyour scripts' directory. It has no 3-rd party dependencies.\n\nYou can also clone the repository and symlink the executable:\n\n```\ncd\ngit clone https://github.com/slomkowski/nginx-config-formatter.git\nln -s ~/nginx-config-formatter/nginxfmt.py ~/bin/nginxfmt.py\n```\n\n\n## Usage as standalone script\n\nIt can format one or several files. Result is by default saved to the original file, but can be redirected to *stdout*.\nIt can also function in piping mode, with `--pipe` switch.\n\n```\nusage: nginxfmt.py [-h] [-v] [-] [-p | -b] [-i INDENT] [config_files ...]\n\nFormats nginx configuration files in consistent way.\n\npositional arguments:\n  config_files          configuration files to format\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -v, --verbose         show formatted file names\n  -, --pipe             reads content from standard input, prints result to stdout\n  -p, --print-result    prints result to stdout, original file is not changed\n  -b, --backup-original\n                        backup original config file as filename.conf~\n\nformatting options:\n  -i INDENT, --indent INDENT\n                        specify number of spaces for indentation\n```\n\n\n## Using as library\n\nMain logic is within `Formatter` class, which can be used in 3rd-party code.\n\n```python\nimport nginxfmt\n\n# initializing with standard FormatterOptions\nf = nginxfmt.Formatter()\n\n# format from string\nformatted_text = f.format_string(unformatted_text)\n\n# format file and save result to the same file\nf.format_file(unformatted_file_path)\n\n# format file and save result to the same file, original unformatted content is backed up\nf.format_file(unformatted_file_path, backup_path)\n```\n\nCustomizing formatting options:\n\n```python\nimport nginxfmt\n\nfo = nginxfmt.FormatterOptions()\nfo.indentation = 2  # 2 spaces instead of default 4\n\n# initializing with standard FormatterOptions\nf = nginxfmt.Formatter(fo)\n```\n\n\n## Reporting bugs\n\nPlease create issue under https://github.com/slomkowski/nginx-config-formatter/issues. Be sure to add config snippets to\nreproduce the issue, preferably:\n\n* snippet do be formatted\n* actual result with invalid formatting\n* desired result\n\n\n## Credits\n\nCopyright 2021 Michał Słomkowski. License: Apache 2.0. Previously published under https://github.com/1connect/nginx-config-formatter.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslomkowski%2Fnginx-config-formatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslomkowski%2Fnginx-config-formatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslomkowski%2Fnginx-config-formatter/lists"}