What’s New ?

The Top 10 favtutor Features You Might Have Overlooked

Read More

Online Compiler: Run R, Python, Java & C++ Code Free

Pick a language, write your code and press Run. Output, error messages and R plots show up right here. Free, no signup, nothing to install.

main.RR 4.6.1
OutputReady
Press Run to see the output here.
optional

Shortcut: Ctrl + Enter runs your code (Cmd + Enter on Mac). Your code stays in this browser, so it is still here when you come back.

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.

LanguageVersionWhat's included
RR 4.6.1ggplot2, dplyr, tidyr and more. Plots show as images.
PythonPython 3.12NumPy and pandas
JavaOpenJDK 21Full Java standard library
C++g++ 13, C++20Full 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() and cor().
  • 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, iris and airquality.
  • 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.

PackageVersionWhat it is for
base R, stats, graphics, utils4.6.1Everything that ships with R
ggplot24.0.3Charts and data visualization
dplyr1.2.1Filter, sort, group and summarise data
tidyr1.3.2Reshape data between wide and long
stringr1.6.0Work with text and regular expressions
readr2.2.0Read CSV text
tibble3.3.1Modern data frames
purrr1.2.2Apply functions over lists
jsonlite2.0.0Read 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.

Vectors and basic statistics
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]
Group and summarise with dplyr
library(dplyr)

mtcars |>
  group_by(cyl) |>
  summarise(cars = n(), avg_mpg = round(mean(mpg), 1), avg_hp = round(mean(hp))) |>
  arrange(desc(avg_mpg))
Scatter plot with ggplot2
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()
Linear regression with a plot
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.

Read input in R
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 messageWhat it means and how to fix it
object 'x' not foundYou 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 constantSomething is missing between two values, usually a comma or an operator. c(5 6) should be c(5, 6).
non-numeric argument to binary operatorYou 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.

Python with input and pandas
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 block means the line after def, if or for needs to be indented. Use 4 spaces.
  • EOFError: EOF when reading a line means your code called input() but the Input box is empty. Type one value per line in the Input box.
  • NameError: name 'totl' is not defined usually 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.

Java with Scanner input
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: ';' expected means 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.

C++ with input
#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 scope means you forgot using namespace std;, or need to write std::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

  1. Pick a language from the tabs: R, Python, Java or C++.
  2. Write your code in the editor, or paste it in. The starter code shows the basic layout.
  3. If your program reads input, type it in the Input box, one value per line.
  4. Press Run or Ctrl + Enter. Output, errors and R plots show on the right.
  5. 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.

LanguageTime limitMemory
R15 seconds640 MB
Python10 seconds384 MB
Java15 seconds640 MB
C++10 seconds512 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.