Online Swift Compiler
Compile and run Swift online with Swift 6.4. Write top-level code in main.swift, press Run, and swiftc builds and starts your program, with compiler errors and output shown beside your code. There is no Mac or Xcode to set up, and programs can read input with readLine as they run.
How to run Swift code online
- This page opens with Swift selected, so you can start typing straight away.
- Write your code in the editor, or open files from your computer: single files, or a whole project as a .zip.
- Press Run, or Ctrl+Enter. The output appears in the panel beside the editor, and when the program asks for input you type it there and press Enter.
- Share a copy with a link, or save your files to your computer.
Swift 6.4 on Online IDE
- Your code is compiled with swiftc, and the top-level code in main.swift runs from top to bottom, with no main function needed.
- print("Enter: ", terminator: "") shows a prompt without a new line, and it appears before the program waits.
- readLine() returns the line you type in the output panel as an optional String, or nil when there is no more input.
- The standard library and Foundation are available, but Swift packages cannot be added.
Example: a Swift program that reads input
print("Enter a sentence: ", terminator: "")
let sentence = readLine() ?? ""
let words = sentence.split(separator: " ")
print("Words: \(words.count)")
print("Backwards: \(words.reversed().joined(separator: " "))")
print("In capitals: \(sentence.uppercased())")
Features of this tool
- Simple and fastA clean, lightweight editor that opens instantly.
- Powered by AceThe Ace code editor, with syntax highlighting, autocompletion and bracket matching.
- Interactive programsType input into the terminal while your program runs.
- Several filesWork in tabs, open files or a .zip from your computer, and save the project back to disk.
- Made for learningHelpful for beginners to learn and practice programs.
- Light and dark themesPlus 39 editor themes, a choice of coding fonts, and Vim, Emacs or VS Code keys.
- Keep your outputCopy or download the program output in one click.
- Share by linkSave your code in the cloud and open it anywhere.
Frequently asked questions
Which Swift version does Online IDE use?
Swift 6.4, compiled with swiftc on Linux.
Can I use SwiftUI or UIKit?
No. Programs run on Linux and print to a terminal, so there are no apps or windows. The Swift standard library and Foundation are available.
How does a Swift program read input?
Call readLine(), which waits for a line you type in the output panel. It returns an optional, so unwrap it with if let or ?? "".
Can I add Swift packages?
No. Swift Package Manager dependencies are not installed, and programs cannot download them.
Contact us
For any feedback, queries or issues, please feel free to contact us or write to . We value your input and are committed to providing the best possible experience for our users.