SwiftUI Playground
Write, run, and share code snippets - no setup required.
Run SwiftUI online and see the app on an iPhone
A free online SwiftUI playground. Write a ContentView and your views appear on an iPhone-sized screen next to the code. Buttons, toggles and text fields respond to taps, so @State changes show up the way they do on a device. No Mac, no Xcode, no simulator to download.
Your code is compiled with swiftc against Coddy's own implementation of SwiftUI, the same one that powers the live preview in Coddy's SwiftUI lessons. It covers the everyday API: stacks, Text, Image(systemName:), Button, Toggle, TextField, Slider, Stepper, Picker, List, ForEach, Form, NavigationStack, sheets and alerts, with @State, @Binding, ObservableObject and @Published. It is not Apple's framework, so Apple-only frameworks such as UIKit, MapKit and Core Data are not available.
What makes this SwiftUI playground useful
- A live iPhone preview: the screen renders at iPhone size in a device frame, with a status bar and the Dynamic Island, so a layout looks the way it would on a phone.
- Tap the app. Buttons, toggles, steppers and text fields respond, and the preview replays your taps against fresh state, so
@Stateand@Bindingbehave as they do in a real app. - Auto preview: the screen rebuilds a moment after you stop typing, and the refresh button starts the app over. Compiler errors point at the line in your file.
- SwiftUI code suggestions in the editor: modifiers after a dot, the values an argument takes (
.font(.,.foregroundStyle(.), property wrappers after@and SF Symbol names. - Save a screenshot of the phone as a PNG, and download your
ContentView.swiftto open in Xcode later. Files pasted from Xcode build too:#Previewblocks are ignored.
What you can build in the SwiftUI playground
- A to-do list with
List,ForEach($items)and aToggleper row, plus aTextFieldand a button that adds new rows. - A settings screen: a
Formwith sections, aPicker, aStepperand aSlider, all bound to@State. - Navigation: a
NavigationStackwith a title andNavigationLinkrows that push a detail view. - Layout experiments:
VStack,HStackandZStackwith.padding,.frame,.backgroundand rounded shapes, to see how modifiers stack.
Online SwiftUI playground FAQ
Can I run SwiftUI without a Mac?
Is the online SwiftUI playground free?
Is this Apple's SwiftUI?
Can I use @Observable or #Preview?
ObservableObject with @Published and @StateObject for shared data. The @Observable macro and #Preview need Xcode's macro plugins; #Preview blocks are ignored, so a file pasted from Xcode still builds, and the app shows ContentView. You can also add your own @main App struct.How do I learn SwiftUI after trying the playground?
@State, lists, navigation, @Binding and observable data in short lessons, each with the same live iPhone preview.Useful tools for SwiftUI
Free, browser-based tools that pair well with the SwiftUI Playground - all part of Coddy.