AI Tools

Code Compactor

Send code to ChatGPT, Claude, or Gemini in fewer tokens. Remove comments and docstrings, or keep only the signatures, and see exactly what you saved.

Compact code locally

Runs locally in your browser. Plain code, no AI model. Your code is not uploaded, saved, or shared.
Options
0 characters

Strings are never changed. The language is detected from the code or the file name.

Compacted
Your compacted code will appear here.

Paste code to compact it.

Ready when you are.

Watch: compact code for AI

No sound. Each step is captioned on screen and also written out in the guide below.

Smaller code in three steps

  1. 01
    Paste code

    A file, a function, or several files one after another.

  2. 02
    Choose how far to go

    Remove comments for code the AI should edit. Keep only signatures to show it the shape of a codebase.

  3. 03
    Copy the result

    See the tokens before and after, then paste it into your prompt.

What each option does

  • Remove comments and docstrings: the code still runs. Comments tools need, like // @ts-ignore or # type: ignore, are kept.
  • Signatures only: function bodies become { … } (or ... in Python); types, classes, and signatures stay.
  • Blank lines and trailing spaces: tidier, though they save few tokens.

Comment-heavy code, like Python with docstrings, often shrinks by a third or more. Signatures alone are often 60–85% smaller.

Frequently asked questions

Will the code still work?

With comments, docstrings, blank lines, and spaces removed, yes: only text the language ignores is removed, and strings are never changed. A Python body left empty by a removed docstring gets pass. "Signatures only" is for reading, not running: function bodies are replaced.

When should I use "Signatures only"?

When the AI needs to know what exists (classes, functions, their parameters and types) but not how each one works. For example, to plan a change across files, or to write code that calls them.

Why are blank lines worth so little?

Tokenizers already pack runs of spaces and line breaks into very few tokens. Removing them makes code shorter to read, but saves little. Comments and function bodies are where the tokens are.

Which languages does it understand?

JavaScript, TypeScript, Python, Java, Kotlin, C, C++, C#, Go, Rust, Swift, PHP, Ruby, shell, SQL, CSS, HTML, and YAML. "Signatures only" works for the languages with braces, and for Python.

Is my code uploaded?

No. Compacting and counting tokens both run in your browser.