Online Code Beautifier

Beautify and format code using conventions, with support for many popular languages

Tags: beautify code c c# c++ css go html java javascript perl php python ruby sql typescript

🚀 279,013 total conversions (19 this month)

Practice Python with coding challenges

Solve hands-on problems right in this editor: run the sample tests, submit, and get an AI code review.

All Python challenges
Easy

Average of Three

Average three whole numbers.

You'll learn ArithmeticDivision
BeginnerLearning-pathVariables
Easy

Rectangle Perimeter

Compute the perimeter of a rectangle from its sides.

You'll learn ArithmeticReturn values
BeginnerLearning-pathVariables
Medium

One Generation of a Genetic Algorithm

Breed the next generation of bit strings with tournament selection, single-point crossover and mutation.

You'll learn Genetic algorithmsEvolutionary search
OptimizationSimulationai
No solutions yet
Easy

Epsilon-Greedy Multi-Armed Bandit

Balance exploration and exploitation on a multi-armed bandit with epsilon-greedy action selection.

You'll learn Explore vs exploitBandits
Reinforcement learningaimachine learning
No solutions yet
Easy

Markov Chain State Distribution

Propagate a probability distribution through a Markov chain's transition matrix for a number of steps.

You'll learn Markov chainsProbability
Simulationaimath
No solutions yet
Medium

Value Iteration

Compute how valuable each state of a Markov decision process is by repeatedly applying the Bellman optimality update.

You'll learn Bellman equationMDPs
Reinforcement learningaimachine learning
No solutions yet
Medium

Q-Learning Updates

Apply the Q-learning update to a stream of experiences and watch rewards flow back to earlier states.

You'll learn Q-learningDiscounted rewards
Reinforcement learningaimachine learning
No solutions yet
Medium

Alpha-Beta Pruning

Evaluate a game tree with minimax and alpha-beta pruning, and count how many leaves the search really looks at.

You'll learn Alpha-beta pruningGame search
RecursionTreesai
No solutions yet
Medium

Minimax Tic-Tac-Toe

Pick the perfect tic-tac-toe move by searching the whole game tree with minimax.

You'll learn MinimaxGame trees
Recursionai
No solutions yet
Medium

A* Search on a Weighted Grid

Find the cheapest path across a grid of terrain costs with A*, the search algorithm behind game and robot pathfinding.

You'll learn A* searchHeuristics
GraphsGridsShortest-pathai
No solutions yet
Medium

Temperature and Top-K Sampling

Choose the next token like a language model does: keep the top k logits, apply temperature, and sample.

You'll learn Text generationSampling
aimachine learning
No solutions yet
Hard

Multi-Head Self-Attention

Project the input into queries, keys and values, run attention in several heads in parallel, and combine them.

You'll learn Multi-head attentionMatrix projections
aimachine learning
No solutions yet

Introduction

Welcome to our online code beautification tool! It’s designed to help you format, clean, and organize your code with ease. Whether you're working with markup, front-end, or back-end languages, we've got you covered. Our tool supports 22 popular programming languages, and you can see the full list in the table on the right.

Powered by advanced beautifiers, this tool gives you the flexibility to style your code exactly how you like. We frequently update the beautifiers to ensure you always get the best performance and the latest features.

How to Use It

Getting started is simple:

  1. Paste or Upload Your Code: You can either paste your code directly into the editor or upload a file using the Upload button. Check the supported file types in the list on the right.
  2. Format Your Code: Choose your preferred settings and let the tool work its magic to clean and beautify your code.
  3. Save or Share: Once your code is formatted, you can download the result, share it via a unique link, or save it to your account by signing in with Google or GitHub.

That’s it! In just a few clicks, your code will be beautifully organized and ready to go.

Examples

Unbeautified:

      
#include <stdio.h>

int main()
{
int n, count, sum = 0;

printf("Enter the value of n(positive integer): ");
scanf("%d",&n);

for(count=1; count <= n; count++){sum = sum + count;}

printf("Sum of first %d natural numbers is: %d",n, sum);

return 0;
}
      
    

After beautified:

      
#include <stdio.h>

int main() {
  int n, count, sum = 0;

  printf("Enter the value of n(positive integer): ");
  scanf("%d", &n);

  for (count = 1; count <= n; count++) {
    sum = sum + count;
  }

  printf("Sum of first %d natural numbers is: %d", n, sum);

  return 0;
}
    
    

Supported languages

# Language Beautifiers Supported Upload Files
1 C ClangFormat **/*.c **/*.cats **/*.cl **/*.h **/*.idc
2 C# Pretty Diff **/*.cs **/*.cake **/*.cshtml **/*.csx
3 C++ ClangFormat **/*.cpp **/*.c **/*.c++ **/*.cc **/*.cp **/*.cxx **/*.h **/*.h++ **/*.hh **/*.hpp **/*.hxx **/*.inc **/*.inl **/*.ino **/*.ipp **/*.re **/*.tcc **/*.tpp
4 CSS Pretty Diff **/*.css
5 ColdFusion Pretty Diff **/*.cfc **/*.cfm **/*.cfml
6 Go Gofmt **/*.go
7 GraphQL Prettier **/*.gql **/*.graphql
8 HTML Pretty Diff **/*.htm **/*.html **/*.xhtml
9 HTML+ERB Pretty Diff **/*.html.erb **/*.erb
10 JSX Pretty Diff **/*.js **/*.jsx
11 Java Pretty Diff **/*.java
12 JavaScript Pretty Diff **/*.js **/*.es **/*.es6
13 Less Pretty Diff **/*.less
14 Objective-C ClangFormat **/*.h **/*.m **/*.mm
15 PHP PHP-CS-Fixer **/*.php
16 Python Black **/*.py
17 Ruby RuboCop **/*.rb
18 SCSS Pretty Diff **/*.scss
19 SQL sqlformat **/*.sql
20 SVG Pretty Diff **/*.svg
21 TypeScript Pretty Diff **/*.ts **/*.tsx
22 XML Pretty Diff **/*.xml **/*.xhtml