Remove comments from
Swift code.
Strip comments from Swift code online. Handles nested block comments, multiline string literals, and string interpolation safely.
.swift filesBefore and after
Real-world Swift code on the left. The same code with every comment removed on the right.
import Foundation
/// Repository for customer orders.
public class OrderRepository {
// Backing store
private let store: OrderStore
/* Initialize with an injected store. */
public init(store: OrderStore) {
self.store = store // remember
}
/// Find an order by id.
/* nested /* still inside */ comment */
public func findById(_ id: UUID) -> Order? {
// Quick guard
guard !id.uuidString.isEmpty else { return nil }
return store.lookup(id) // delegate
}
public var query: String {
"""
SELECT * FROM orders
WHERE note = "// not a comment"
"""
}
}import Foundation
public class OrderRepository {
private let store: OrderStore
public init(store: OrderStore) {
self.store = store
}
public func findById(_ id: UUID) -> Order? {
guard !id.uuidString.isEmpty else { return nil }
return store.lookup(id)
}
public var query: String {
"""
SELECT * FROM orders
WHERE note = "// not a comment"
"""
}
}Built for Swift specifically.
Swift's documentation comments (/// and /** */) and inline `//` notes pile up quickly in iOS / macOS projects. Removing them produces cleaner snippets for code reviews, blog posts, and minimal reproducible examples. Swift is one of the few languages with nested block comments, Uncommenter handles them correctly.
- // and /* */ comments removed
- Nested /* /* */ */ block comments handled at any depth
- Multiline string literals ("""...""") preserved
- String interpolation \(value) kept intact
- Auto-detected from .swift files
Strip comments in 30 seconds.
- 1
Open the tool
Head to uncommenter.com/tool. Nothing to install. Nothing to sign up for.
- 2
Paste your Swift code
Drop your .swift file in, or paste code into the editor. Auto-detection picks up Swift from the extension or file content.
- 3
Click 'Remove Comments'
The parser walks every character with a real state machine, strings, regex, and other context-sensitive parts are detected and left alone.
- 4
Copy or download
Grab the cleaned output. Your code never left your browser.
Swift questions, answered.
Does it support nested block comments?
+
Yes, Swift's spec allows arbitrarily nested /* */ comments. The parser tracks depth and removes the entire outermost block.
Are multiline string literals safe?
+
Yes. """triple-quote""" string literals are detected as string state. // and /* inside them are preserved.
What about MARK and TODO comments?
+
By default they're removed. Pass `options.preserveTodos: true` to keep TODO/FIXME-style markers (which also covers MARK by convention) while removing the rest.
Working in something else?
Plus 35+ more languages supported in the live tool , including HTML, YAML, Dockerfile, Terraform, Solidity, and more.
Try it on your Swift code now.
Free forever. No signup. No upload. Runs entirely in your browser.
Open uncommenter