Discuvr Python Formatter

Office & Data

CSV to Excel Paste CSV and see it as a spreadsheet instantly, with numbers, dates and IDs typed the way Excel should hold them. Download a clean .xlsx only when you want it. Sign PDF Sign a PDF in your browser - draw, type or upload your signature, place it on any page, add the date, and download the signed copy. The file never leaves your device. Redact Permanently redact PDF, Word, Excel, PowerPoint, text and image files. Matches and boxes are removed from the file itself, not covered up, and the result is checked again before you download it. What is my IP See the public IP address websites see when you connect, whether it is shared (CGNAT) or private, and what else your browser reveals. Case Converter & Line Tools Change text to UPPER, lower, Title or Sentence case, turn names into camelCase or snake_case, and remove duplicate lines or sort a list. Text Compare Paste two versions of a text to see every added, removed and changed line, with the changed words highlighted.

Writing & Proposals

Tone Polish Reformat what you wrote with proper grammar, structure and articulation - in your own voice. One paste, one reply, no chat session. Freelance Proposal Generator Describe a client problem and get a scoped, priced, ready-to-send freelance proposal in seconds.

Legal & Compliance

IP Law Q&A Chatbot Ask questions about Indian IP law - trade marks, patents, copyright, designs and more, with the web search results it used listed above each answer. Patent FER Reply Generator Paste the objections from a First Examination Report to draft a structured reply, or upload a draft for an IP risk review. Government Scheme Eligibility Finder Answer a short set of questions once. Sign in and we save your answers, so you can check which central government schemes you may qualify for without retyping them.

Privacy & Security

Website Security Scan Scan a domain for real, reproducible security weaknesses. Every finding carries the observation behind it and the command to verify it yourself. Image Scrub See exactly what your photo reveals about you - GPS, camera serial, your name - then strip it. Crop, resize, blur faces and convert, all without the image being stored anywhere.

Developer Tools

JSON Formatter Beautify, minify and validate JSON in one paste - with the exact line and column when it will not parse, and a count of what is actually in the document. Python Formatter Reformat Python the way Black would, with the line length and quote handling you choose - and a count of exactly how many lines changed. HTML Viewer Paste HTML and see it rendered live in a sandbox, at phone, tablet or desktop width - with beautify, minify, a console for scripts and a report of what is broken in the markup. IP Subnet Calculator Enter CIDR notation or an IP with a netmask and get the network address, broadcast address, usable host range and total address count instantly. Encode / Decode Encode or decode Base64, Base64URL, URL percent-encoding, HTML entities and hex as you type, with full UTF-8 support. Unix Timestamp Converter Convert a Unix epoch timestamp in seconds, milliseconds, microseconds or nanoseconds to a date in UTC or a major world time zone, and a date back to a timestamp. System Diagram Maker Type arrows like User -> API -> Database and get a laid-out architecture or flow diagram. Fold groups into one box for the big picture, number the steps for a detailed flow.

AI Workbench

AI Playground Compare responses from multiple LLM providers side by side in real time. Bring your own API keys. Agent Playground Experiment with AI agents that use tools - web search, a calculator, URL fetching - across multiple providers.

Learning

Study Buddy An interview-prep coach for top tech jobs, from the first study day to an accepted offer: a plan across DSA, LLD, system design, behavioural and AI-assisted coding, mock interviews, a resume review, an applications tracker and offer comparison.

Everyday Helpers

QR Code Generator Create QR codes from text, URLs, WiFi credentials or contact info - as PNG images or SVG vectors, with the error correction level you choose. Unit Converter Convert between length, weight, temperature, volume, speed, area and energy units instantly - 40+ unit types with instant results. Password Generator Generate a random password with cryptographically secure randomness, tune its length and character types, and see its strength in bits of entropy. Word Counter & Readability Analyzer Count words, characters, sentences and paragraphs, estimate reading time, and score readability - with true character-based counting for Chinese, Japanese, Korean and Thai text. Age / Date Difference Calculator Find someone's exact age, or the exact difference between any two dates - years, months and days, plus the total number of days and weeks. Date Difference Calculator Count the days, weeks, months and working days between two dates, or add and subtract days from a date. Percentage Calculator Calculate X% of Y, what percent one number is of another, percentage increase or decrease between two numbers, or reverse percentage - four common calculations in one tool. SIP Calculator See what a monthly investment grows to, with a yearly step-up, a starting lump sum and inflation, or find the monthly amount a goal needs. BMI Calculator Calculate your Body Mass Index (BMI) from height and weight, in metric or imperial units, classified against the WHO adult categories - underweight, normal, overweight, obese.
Sign in Get started
All toolsDeveloper Tools

Python Formatter

Reformat Python the way Black would - and see exactly how many lines it changed.

Your code

0 characters

Formatted

 

About Python Formatter

This runs Black - the formatter most Python projects already agree on - over whatever you paste, with the line length and quote handling you choose. If the file does not parse it says which line, and if it is already formatted it says that too rather than pretending to have done something.

What it does

  • Black formatting at 79, 88, 100 or 120 columns.
  • "Check only" mode: find out whether a file would change without changing it.
  • Keep your own quote style, or let Black normalise it.
  • Honour or ignore the magic trailing comma that keeps a collection exploded.
  • Target a specific Python version when the syntax is version-sensitive.
  • Syntax errors report the line, the column and the code around it.
  • Reports how many lines were added and removed, plus the file's shape.

How it works

  1. 1 Paste the code, or a file's worth of it.
  2. 2 Choose a line length and any options you care about.
  3. 3 Press Format, then copy or download the result.

Your code is never executed

Formatting Python does not require running it. The code is parsed into a syntax tree and rewritten from that tree, entirely in memory - it is never written to a file, never imported and never executed. A formatter that ran what you pasted would be a remote shell with a text box.

Why Black, and not an opinion of our own

Black is an AST-preserving transform: the code that comes out is the same program as the code that went in. That property is the whole reason a formatter can be trusted, and it is why no language model is involved anywhere in this tool. A model asked to tidy code will occasionally rewrite a line while it is there, and a silent change to working code is the one failure a formatter cannot afford.

Check only

The same question CI asks: would this file change? Check mode returns your original code untouched and reports whether Black would have reformatted it, and by how many lines. It is the quick way to find out why a pipeline is failing on a file you cannot reproduce locally.

Magic trailing comma and fmt: off, worked examples

A comma after the last item tells Black to keep a call or collection one item per line: result = compute(alpha, beta,) comes back as four lines, with alpha, and beta, each on its own line. Tick Ignore magic trailing comma and the same input becomes result = compute(alpha, beta) whenever it fits the line length. To protect a hand-aligned block such as a matrix, put # fmt: off on the line above it and # fmt: on below it, and Black leaves everything in between as you wrote it; # fmt: skip at the end of a line protects that one line. These are Black's own comments, so they keep working when your project's CI runs Black.

Questions

Is my code uploaded or stored?

It is sent to the server, formatted in memory and returned in the same response. Nothing is written to disk, cached or logged, and the usage record keeps only counts - size, options, how many lines changed - never the code.

Does formatting change what my code does?

No. Black changes layout, not behaviour, but it does more than move spaces. It removes redundant parentheses (x = (1) becomes x = 1), lower-cases number prefixes and exponents (0XABCDEF becomes 0xABCDEF, 1E5 becomes 1e5), adds a trailing comma when it splits a call over several lines, collapses runs of blank lines and trims the spaces inside a docstring (""" Doc. """ becomes """Doc."""). That last change alters the text of __doc__, which matters only if your code reads its own docstrings.

Why did it not reformat my file at all?

Because it was already formatted at the line length you chose. The tool says "already formatted" rather than quietly returning a copy.

Does it sort my imports?

No. Import sorting is isort's job, not Black's, and the two disagree often enough that doing it here would surprise you.

Can it format a file with a syntax error?

No formatter can - an unparseable file has no structure to rewrite. You get the line, the column and the surrounding code so you can fix it and try again.

Does it follow PEP 8?

Black is PEP 8 compatible with one well-known deviation: its default line length is 88 rather than 79. Pick 79 in the line length selector if you need the stricter figure.

How large a file can I format?

Up to 400,000 characters per run. Formatting stops after 10 seconds, which only very large or deeply repetitive files reach, and each IP address can run 30 formats every 10 minutes.

How do I get the same formatting in my editor, pre-commit or CI?

This page runs Black, and its version is shown in the page header on wide screens. Black reads project settings from pyproject.toml under [tool.black], using the long option names: line-length = 88 for the "Line length" you picked, skip-string-normalization = true if you ticked "Keep my quotes", skip-magic-trailing-comma = true for "Ignore magic trailing comma", and target-version = ["py311"] for a fixed "Target". Editor plugins and the pre-commit hook read the same file. Run black . to format and black --check --diff . in CI: it changes nothing and exits with code 1 when a file would be reformatted. Pin the same Black version as this page, because the first release of each calendar year may change the stable style.

Is the output the same as Ruff's formatter (ruff format)?

Almost always, but not byte for byte. Ruff's formatter is designed as a drop-in replacement for Black, and Ruff's documentation reports that on large Black-formatted projects such as Django and Zulip more than 99.9% of lines come out identical. It differs more on code that was never Black-formatted, especially around end-of-line comments, and its documentation lists its intentional deviations. Its default line length is also 88, set with line-length under [tool.ruff]; quote-style = "preserve" under [tool.ruff.format] matches "Keep my quotes" and skip-magic-trailing-comma = true matches "Ignore magic trailing comma". If your CI runs ruff format --check, test the file with Ruff, not with this page.