XCODX |

F# Online Compiler & Interpreter

Select Language
Online Code Compiler
Full HTML IDE
Py main.py
Program Output Ready
  Welcome to XCODX Online Compiler

  Quick Start:
  Ctrl+Enter  Run code
  Ctrl+S      Save / Download
  Ctrl+L      Clear output

  Select a language and start coding.
Success
Operation completed

About F#

F# is Microsoft's answer to the question 'what if ML met .NET?' Designed by Don Syme at Microsoft Research and now developed in the open, F# delivers succinct functional-first code — immutability by default, algebraic data types, pattern matching, the pipeline operator — with full access to the entire .NET ecosystem. F# 9 shipped alongside .NET 9 (November 2024) with nullable reference type interop and performance work. Production users include fintech and energy-trading firms, and features F# pioneered (records, pattern matching) have steadily migrated into C#. This variant compiles your code as a .NET program. The terminal on this page is fully interactive: Console.ReadLine waits for your real keystrokes while output streams live.

Hello World in F#

open System

printf "What's your name? "
let name = Console.ReadLine()
printfn "Hello, %s!" name

printf "Enter numbers separated by spaces: "
let numbers =
    Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries)
    |> Array.map float

numbers
|> Array.map (fun x -> x * x)
|> Array.sum
|> printfn "Sum of squares: %g"

let parity n = if n % 2 = 0 then "an even" else "an odd"
printfn "You entered %d values - %s count." numbers.Length (parity numbers.Length)

When to use F#

F# appeals to two overlapping groups: .NET developers who want functional programming without leaving their platform, and functional programmers who need .NET's libraries and jobs. Practicing here covers what F# interviews and coursework emphasize — pipelines, discriminated unions, records, recursion, and Option handling — without installing the .NET SDK. It's also useful for C# developers evaluating F# for a data-processing or domain-modeling component, a common adoption path since both compile to the same IL and interoperate freely in one solution.

Common questions

Is Console.ReadLine interactive on this page?

Yes. The compiled program runs attached to a live terminal, so Console.ReadLine blocks until you type a line, and printf/printfn output appears as it executes. You can chain several prompts — read a name, then numbers, then options — and watch each pipeline stage respond in real time.

What's the difference between this and the F# Interactive (fsi) variant?

This variant compiles your file as a .NET program and runs the resulting binary — full compilation, matching how production F# ships. The fsi variant evaluates your code through F# Interactive's script engine instead, which skips the build step. Same language and same results for typical code; choose fsi for quicker iteration.

Can I reference NuGet packages or multiple files?

No — execution is a single file with no NuGet restore, so external packages aren't available. What you do get is substantial: the entire .NET base class library (System.*, collections, LINQ from F#, regex, math) plus F#'s own FSharp.Core with List, Array, Seq, Map, Option, and Result modules.

How F# runs on XCODX

Sandbox filename
main.fs
Entry point
main.fs entrypoint
Editor grammar
mllike
Reading stdin
Console.ReadLine()
Input delivery
live WebSocket stream
Prompt flushing
flush manually before reading input
Compile limit
10 s
Run limit
3 s batch · up to 3 min live
Memory
256 MB per stage
Max source
50,000 characters

Default program on this page

// F# .NET Program
printfn "Hello from F#.NET!"
printfn "Welcome to XCODX Online Compiler!"

let numbers = [1..10]
let sum = List.sum numbers
let evens = List.filter (fun x -> x % 2 = 0) numbers
printfn "Numbers: %A" numbers
printfn "Sum: %d" sum
printfn "Evens: %A" evens

The .NET toolchain emits a spurious "Can't rename" line during compilation. It is suppressed on a successful build.