Code Explainer with Local AI

Paste code in any common language to see its structure, a note for each line and refactoring hints; load a small offline AI model for deeper explanations.

Działa w Twojej przeglądarce. Twoje pliki nigdy nie opuszczają urządzenia. Zobacz, jak to sprawdzić

…

Jak to zrobić

  1. 1
    Paste code

    Paste the code into the editor; the language is detected automatically.

  2. 2
    Check the structure

    Read imports, classes and the function table with complexity and nesting.

  3. 3
    Read line notes

    Open Line by line to see a note next to each line.

  4. 4
    Review hints

    Open Refactor hints and jump to the lines mentioned.

  5. 5
    Load the model

    In the AI tab read the notice and press Load the AI model.

  6. 6
    Ask for explanations

    Choose Line by line, Summary, Refactor ideas or Big-O and press Explain.

O tym narzędziu

Reading someone else's code is a daily task: a legacy module, a snippet from an answer online, a script a colleague left behind. This explainer gives you three exact views computed from the text and one AI view. The structure view lists imports, classes and every function with its line range, length, maximum nesting and cyclomatic complexity, the number of independent paths that Thomas McCabe defined in 1976. The line view puts a short plain-English note next to each line, such as loops over each item in values or handles errors from the try block. The hints view flags long functions, deep nesting, loose equality, bare except clauses, magic numbers, duplicated lines and eval. The AI view asks a local model for a line-by-line walkthrough, a summary, refactor ideas or Big-O analysis.

Who this is for

Students learning to read code, developers joining a new codebase, reviewers, and people who maintain scripts they did not write.

Supported languages

Detection is automatic for JavaScript, TypeScript, Python, Java, C#, Go, PHP, Ruby, Rust, C, C++, Kotlin, Swift, SQL and shell scripts, and you can override it. Functions are found with language-specific patterns; blocks end at the matching brace or, for Python and Ruby, where the indentation returns.

Complexity numbers

Cyclomatic complexity is 1 plus the number of decision points: if, else if, loops, case labels, catch blocks, the && and || operators and ternaries. A score up to 5 is simple, 6 to 10 needs care, and above 10 the function is hard to test fully and is a candidate for splitting. Strings and comments are blanked before counting, so a word like "if" inside a message is not counted.

Line notes

Notes cover imports, class and function definitions with their parameters, conditions, loops, error handling, returns, assignments, calls, prints and awaits. Lines that are only braces are marked as closing a block. These notes describe syntax, not intent; the AI view is better at explaining why.

Refactor hints

Each hint points to a line: complexity above 10, functions over 50 lines, nesting deeper than three levels, more than five parameters, lines over 120 characters, var and == in JavaScript, any in TypeScript, bare or silent except clauses, empty catch blocks, magic numbers, open TODO or FIXME comments, eval and repeated lines that could become a shared function.

Local AI

After you agree to the download, about 555 MB of model weights load from the Hugging Face CDN and are cached. The model runs with WebGPU when available, otherwise on the CPU through WebAssembly. Only the first 6,000 characters of your code are used, and they stay on your device. Answers stream in as they are written and are kept per mode in the project.

Worked example

The sample Python function load_orders reads a JSON file, skips cancelled orders and sums quantity times price per customer. The structure view shows imports json and pathlib, one function on lines 4 to 15 with complexity 5 (two if statements and two for loops) and nesting 2. The line notes explain continue as skipping to the next loop round and the sorted call as a return of totals by value, largest first.

Limits

The exact views use patterns, not a full parser for every language, so unusual formatting can hide a function. Small AI models make mistakes, especially with rare libraries or long files; check explanations against the code and documentation. Nothing here executes your code.

Przykład z rozwiązaniem

load_orders(): lines 4–15, complexity 5, nesting 2, imports json and pathlib.

W skrócie

Najczęstsze pytania

What is cyclomatic complexity?

The number of independent paths through a function: 1 plus the decision points. Higher numbers need more tests to cover.

Does it run my code?

No. It only reads the text; nothing is executed.

Can I use it offline?

After the model has been downloaded once, the AI view works from the browser cache; the exact views never need a network.

How big is the AI download?

About 555 MB for Qwen2.5-Coder-0.5B-Instruct, downloaded once after you press the button.

Why are some functions missing from the outline?

Very unusual formatting or language features can defeat the patterns. Choose the language manually or reformat the code.

Is the code sent to a server?

No. All analysis and the AI model run in your browser.

Całkowicie za darmoBez opłat i rejestracji
Pliki zostają prywatneWszystko działa w Twojej przeglądarce
Łatwo w Twoim językuDostępne w wielu językach