A free online compiler for 4 languages
FavTutor's online compiler lets you write and run code in R, Python, Java and C++ from your browser. Your code runs on our server in a few seconds and the output comes straight back to this page. It's free, there's no signup, and it works on laptops, Chromebooks, tablets and phones.
| Language | Version | What's included |
|---|---|---|
| R | R 4.6.1 | ggplot2, dplyr, tidyr and more. Plots show as images. |
| Python | Python 3.12 | NumPy and pandas |
| Java | OpenJDK 21 | Full Java standard library |
| C++ | g++ 13, C++20 | Full STL, including bits/stdc++.h |
Every language supports input through the Input box, shows the real error message when something breaks, and remembers your code in your browser.
Online R compiler
The R compiler runs R 4.6.1, the same R you would install on your own computer. Type your script, press Run, and the output appears in a second or two. You don't need RStudio, you don't need to install R, and you don't need an account.
The part most online R compilers miss is graphics. Here, plots show up right under your output. Call plot(), hist(), barplot() or boxplot(), or build a ggplot, and you'll see the chart as an image. You can make up to six plots in one run, and save any of them with a right-click.
What you can do with the R compiler
- Practice R basics like vectors, lists, matrices, factors and data frames.
- Run statistics with
mean(),sd(),summary(),t.test(),lm()andcor(). - Draw charts with base R graphics or ggplot2.
- Clean and reshape data with dplyr and tidyr, using the pipe
|>or%>%. - Work with built-in datasets such as
mtcars,irisandairquality. - Check a line of code from your statistics assignment before you submit it.
R packages included
These packages are installed and ready. Load them with library() as usual.
| Package | Version | What it is for |
|---|---|---|
| base R, stats, graphics, utils | 4.6.1 | Everything that ships with R |
| ggplot2 | 4.0.3 | Charts and data visualization |
| dplyr | 1.2.1 | Filter, sort, group and summarise data |
| tidyr | 1.3.2 | Reshape data between wide and long |
| stringr | 1.6.0 | Work with text and regular expressions |
| readr | 2.2.0 | Read CSV text |
| tibble | 3.3.1 | Modern data frames |
| purrr | 1.2.2 | Apply functions over lists |
| jsonlite | 2.0.0 | Read and write JSON |
install.packages() won't work, because the compiler has no internet access. If you need a package that isn't listed, email [email protected] and we'll look at adding it.
R code examples
Press Try it to load an example into the compiler above and run it.
marks <- c(56, 78, 91, 64, 88, 73)
names(marks) <- c("Asha", "Ben", "Chen", "Dev", "Ella", "Farid")
print(marks)
cat("Highest:", names(which.max(marks)), "with", max(marks), "\n")
cat("Mean:", mean(marks), " SD:", round(sd(marks), 2), "\n")
marks[marks > 70]library(dplyr)
mtcars |>
group_by(cyl) |>
summarise(cars = n(), avg_mpg = round(mean(mpg), 1), avg_hp = round(mean(hp))) |>
arrange(desc(avg_mpg))library(ggplot2)
ggplot(iris, aes(Sepal.Length, Petal.Length, colour = Species)) +
geom_point(size = 2) +
geom_smooth(method = "lm", se = FALSE) +
labs(title = "Iris: sepal vs petal length", x = "Sepal length", y = "Petal length") +
theme_minimal()model <- lm(mpg ~ wt, data = mtcars)
summary(model)
plot(mtcars$wt, mtcars$mpg, pch = 19, col = "steelblue",
xlab = "Weight (1000 lbs)", ylab = "Miles per gallon")
abline(model, col = "red", lwd = 2)How to take user input in R
Type your values in the Input box, one per line, then read them with readLines(). Each line becomes one element of the result. readline() does not wait for input when R runs a script, so use readLines() instead.
con <- file("stdin")
input <- readLines(con)
close(con)
name <- input[1]
n <- as.numeric(input[2])
cat("Hi", name, "\n")
for (i in 1:5) cat(n, "x", i, "=", n * i, "\n")Common R errors and how to fix them
| Error message | What it means and how to fix it |
|---|---|
object 'x' not found | You used a variable before creating it, or spelled it differently. R is case sensitive, so Total and total are different. |
could not find function "mea" | The function name is misspelled, or it lives in a package you haven't loaded. Fix the spelling or add library(dplyr) (or the right package) at the top. |
unexpected numeric constant | Something is missing between two values, usually a comma or an operator. c(5 6) should be c(5, 6). |
non-numeric argument to binary operator | You tried to do maths on text, like "5" + 2. Convert it first with as.numeric(). |
there is no package called 'caret' | That package isn't installed here. Use one from the package list above, or email us to request it. |
Online Python compiler
The Python tab runs Python 3.12. It's handy for checking homework answers, testing a function, or learning Python without setting anything up. input() reads from the Input box, and NumPy and pandas are installed, so you can try data work too.
import pandas as pd
n = int(input())
df = pd.DataFrame({"n": range(1, n + 1)})
df["square"] = df["n"] ** 2
print(df.to_string(index=False))Common Python errors
IndentationError: expected an indented blockmeans the line afterdef,iforforneeds to be indented. Use 4 spaces.EOFError: EOF when reading a linemeans your code calledinput()but the Input box is empty. Type one value per line in the Input box.NameError: name 'totl' is not definedusually means a typo in a variable name.
Online Java compiler
The Java tab uses Java 21 (OpenJDK). Write a class with a main method and keep that class first in the file. The class can have any name, though Main is the usual choice. Read input with Scanner as you normally would.
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
List<Integer> nums = new ArrayList<>();
while (sc.hasNextInt()) nums.add(sc.nextInt());
Collections.sort(nums);
System.out.println("Sorted: " + nums);
System.out.println("Sum: " + nums.stream().mapToInt(Integer::intValue).sum());
}
}Common Java errors
error: ';' expectedmeans a statement is missing its semicolon. The caret^in the message points to where Java expected it.- If nothing runs, check that the class with
public static void main(String[] args)is the first class in the file.
Online C++ compiler
The C++ tab compiles with g++ 13 using C++20 and -O2. The full standard library is available, including <bits/stdc++.h>, so it works well for competitive programming practice. If your code doesn't compile, you'll see the exact compiler error with the line number.
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (auto &x : a) cin >> x;
sort(a.begin(), a.end());
cout << "Min: " << a.front() << ", Max: " << a.back() << "\n";
return 0;
}Common C++ errors
'cout' was not declared in this scopemeans you forgotusing namespace std;, or need to writestd::cout.- Exit code 139 is a segmentation fault. Your program read memory it shouldn't, often an array index out of range or a null pointer.
How to use the online compiler
- Pick a language from the tabs: R, Python, Java or C++.
- Write your code in the editor, or paste it in. The starter code shows the basic layout.
- If your program reads input, type it in the Input box, one value per line.
- Press Run or Ctrl + Enter. Output, errors and R plots show on the right.
- Use Download to save your code as a file, or Reset to start again.
You can link straight to a language. favtutor.com/compiler#python opens the Python compiler, and #r, #java and #cpp work the same way.
Limits
The compiler is free for everyone, so each run has a few limits. They're generous for learning and practice.
| Language | Time limit | Memory |
|---|---|---|
| R | 15 seconds | 640 MB |
| Python | 10 seconds | 384 MB |
| Java | 15 seconds | 640 MB |
| C++ | 10 seconds | 512 MB |
- Programs can't reach the internet, so downloads, APIs and package installs won't work.
- Output is capped at 64 KB of text per run.
- Files your program writes are deleted when the run ends.
- Each run starts fresh, so run the whole script each time.
Why use an online compiler instead of installing one
If you code every day, install R, Python, a JDK or a C++ compiler on your own machine. For a lot of people that's more than they need. If you're checking an answer for an assignment, following a tutorial, or helping a friend fix a few lines, an online compiler gets you there faster.
It also helps when you're not on your own computer. Lab machines often block installs, and phones and iPads can't run R or a C++ compiler at all. This page works in any modern browser.
Stuck on an error you don't understand? Paste it into our AI code debugger for a plain-English explanation. For bigger projects, you can get one-on-one help from an expert in R, Python, Java or C++.
Frequently asked questions
Is this online compiler free?
Yes. The R, Python, Java and C++ compilers are free with no signup and no daily limit. There is a short cooldown only if one person sends a very large number of runs in a single minute.
Which languages does the online compiler support?
R 4.6.1, Python 3.12, Java 21 (OpenJDK) and C++20 with g++ 13. Pick one from the tabs above the editor.
Can I make plots in the online R compiler?
Yes. Base R plots like plot(), hist() and boxplot() work, and so does ggplot2. Each plot shows as an image under your output, up to six per run. Right-click a plot (or long-press on a phone) to save it.
Can I install packages?
No. The compiler has no internet access, so install.packages() and pip install fail. Popular packages are already installed: ggplot2, dplyr, tidyr and more for R, and NumPy and pandas for Python.
How do I give input to my program?
Type it in the Input box under the output, one value per line. Read it with input() in Python, Scanner in Java, cin in C++ and readLines(file("stdin")) in R.
Is my code saved?
Your code is saved in your own browser, so it's still there when you come back on the same device. It is not kept on our server after the run finishes.
Why does my Java code not run?
Make sure the class with public static void main(String[] args) is the first class in the file. The class can have any name. Helper classes can go below it.
Does the online compiler work on mobile?
Yes. The editor, output and R plots all work on phones and tablets. Long lines wrap so you don't have to scroll sideways.
