C++ Playground
This C++ playground is a C++ sandbox that compiles your code in your browser, with Clang and C++20. Write it, press Run and read the output, or the compiler’s errors, in the console. Nothing to install and no account to start. Sign in to save and share a link. It’s part of Playcode Classic, Playcode’s free code tools.
Free. No account needed to start.

What this C++ playground compiles
| Compiler | Clang, compiled to WebAssembly, running in your browser |
|---|---|
| Standard | C++20, with -O2 and warnings on (-Wall -Wextra) |
| Library | Containers, strings, algorithms and streams; #include <bits/stdc++.h> works |
| Files | main.cpp is compiled; other files aren’t yet |
| Input (cin) | Not yet: put the values in your code |
| Exceptions | Off: code that throws doesn’t compile |
| Errors | Clang’s errors and warnings, in the console |
| Stop | Ends any program, an endless loop included |
| Run | Ctrl+R |
| Phone | Yes, in your phone’s browser |
Errors a page long? The AI reads them for you.
Clang says what went wrong, sometimes at length. Ask the editor’s AI chat: it already sees the errors in your console, then explains them or fixes the code. It uses credits; eligible new accounts get trial credits.

C++ to try
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> scores =
{72, 95, 61, 88};
sort(scores.begin(),
scores.end(),
greater<int>());
for (int s : scores)
cout << s << ' ';
cout << '\n';
}95 88 72 61#include <iostream>
#include <numeric>
#include <string>
#include <vector>
template <typename T>
T total(
const std::vector<T>& items
) {
return std::accumulate(
items.begin(),
items.end(), T{});
}
int main() {
std::cout << total(
std::vector<int>{1, 2, 3})
<< '\n';
std::cout << total(
std::vector<double>{
0.5, 1.25})
<< '\n';
std::cout << total(
std::vector<std::string>{
"C", "++"})
<< '\n';
}6
1.75
C++#include <iostream>
#include <map>
#include <string>
int main() {
std::map<std::string, int>
stock = {{"apples", 4},
{"pears", 0}};
for (const auto&
[name, count] : stock) {
std::cout
<< name << ": "
<< (count ? "in stock"
: "sold out")
<< '\n';
}
}apples: in stock
pears: sold out
Part of Playcode Classic
Playcode began in 2016 as a browser coding environment. This playground is one of its free code tools, which we now call Playcode Classic.
Playcode today is an AI platform for building and running websites and apps.

Questions people ask
Is this online C++ playground free?
Yes. Compiling and running code is free and needs no account. Saving and sharing need a free account, which keeps up to three saved projects, public or private; the AI chat uses credits.
Which compiler and C++ version does it use?
Clang, compiled to WebAssembly, running in your browser. It compiles C++20 with -O2, -Wall and -Wextra.
Do I need to install a compiler?
No. Open it in a browser on a computer or a phone and press Run.
Can my program read input with cin?
Not yet. The playground can’t pass typed input to your program. Put the values in your code instead.
Can I use exceptions?
Not yet. The playground compiles with exceptions turned off, so code that throws doesn’t compile.
Does #include <bits/stdc++.h> work?
Yes.
Can I split my program into several files?
Not yet. The cpp playground compiles one file, main.cpp.
How is this different from the C++ compiler?
Both open the same editor and compiler. Use this page to try ideas; use the C++ compiler page to compile a program and read its output.
Can I run C instead?
Yes, in the C compiler, which runs C in your browser the same way.
Is this playground part of Playcode?
Yes. This playground is part of Playcode Classic, Playcode’s free code tools. Playcode began in 2016 as a browser coding environment. Today it is an AI platform for building and running websites and apps.
More free code tools
- C++ Compiler
Compile a program, read its output.
- C Compiler
Compile and run C in your browser.
- Go Compiler
Run Go in your browser.
- Python Compiler
Run Python, read the output.
- Code Playground
Every language in one place.
- SQL Playground
A database with data already in it.
Write some C++. Press Run.
