[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"extension:v3:en:kts":3},{"resolvedFromAlias":4,"canonicalExt":5,"ext":5,"name":6,"category":7,"categoryName":8,"updatedAt":9,"popularity":10,"summary":11,"howToOs":12,"quickAnswer":18,"answerIntro":19,"whatIs":20,"description":21,"furtherReading":22,"openInstructions":41,"commonIssues":52,"securityNotes":72,"faq":76,"aliases":89,"mimeTypes":90,"relatedExtensions":91,"breadcrumbs":139,"categoryAnchor":149,"categoryFuturePath":150,"metaDescription":151,"availableHowToOs":152,"openOnDeviceLinks":153,"cannotOpenReasons":169,"cannotOpenFixes":170,"convertOptions":171,"securityAffiliateMessaging":172,"securityAffiliates":173},false,"kts","Kotlin Script","code","Code","2026-06-12T09:04:56.042Z",55,".kts is a Kotlin script source file used to run Kotlin code as a script. It can be opened in code editors and executed with the Kotlin command-line compiler.",[13,14,15,16,17],"windows","mac","linux","ios","android","To open .KTS files on Windows, to view/edit: open the .kts file in a code editor (any plain-text editor works for reading).","To open a .kts file, use a text editor or IDE that supports Kotlin to view/edit it, and use the Kotlin command-line compiler (kotlinc -script) to run it. Some .kts files are specifically used as Gradle build scripts when named like build.gradle.kts.","A .kts file is a Kotlin source file in “script” form (Kotlin scripting). It contains Kotlin code meant to be executed directly by the Kotlin compiler in script mode rather than compiled as part of a typical Kotlin project.",".kts is the standard extension for Kotlin scripts. Kotlin is a general-purpose programming language, and its scripting mode lets you run a Kotlin source file directly as a script.\n\nIn practice, many people encounter Kotlin scripts through build tooling: Gradle’s Kotlin DSL uses Kotlin-based build scripts, commonly named build.gradle.kts (and settings.gradle.kts). In that context, the .kts code configures a Gradle build rather than acting as a standalone script.\n\nBecause .kts is plain text code, it can be edited with most programming text editors. Running it depends on having Kotlin tooling (and, for Gradle build scripts, Gradle) set up correctly.",[23,26,29,32,35,38],{"title":24,"url":25},"Kotlin command-line compiler (Kotlin Documentation)","https://kotlinlang.org/docs/command-line.html",{"title":27,"url":28},"Kotlin DSL Primer (Gradle User Manual)","https://docs.gradle.org/current/userguide/kotlin_dsl.html",{"title":30,"url":31},"Build File Basics (Gradle User Manual)","https://docs.gradle.org/current/userguide/build_file_basics.html",{"title":33,"url":34},"Kotlin (programming language) — Wikipedia","https://en.wikipedia.org/wiki/Kotlin",{"title":36,"url":37},"Media Types (IANA) registry","https://www.iana.org/assignments/media-types/",{"title":39,"url":40},"shared-mime-info (freedesktop.org)","https://freedesktop.org/wiki/Software/shared-mime-info/",{"windows":42,"macos":45,"linux":47,"ios":48,"android":50},[43,44],"To view/edit: open the .kts file in a code editor (any plain-text editor works for reading).","To run as a Kotlin script: install the Kotlin command-line compiler and run: kotlinc -script path\\to\\file.kts",[43,46],"To run as a Kotlin script: install the Kotlin command-line compiler and run: kotlinc -script /path/to/file.kts",[43,46],[49],"iOS does not commonly run Kotlin scripts directly; open the file as text for viewing, or transfer it to a desktop system to run with kotlinc -script.",[51],"Android does not commonly run Kotlin scripts directly; open the file as text for viewing, or transfer it to a desktop system to run with kotlinc -script.",[53,59,65],{"title":54,"description":55,"steps":56},"Double-clicking doesn’t run the script",".kts files are source code; most operating systems do not execute them by default when you double-click.",[57,58],"Open the file in a code editor to inspect it as text.","Run it from a terminal with the Kotlin compiler: kotlinc -script file.kts",{"title":60,"description":61,"steps":62},"Trying to run a Gradle Kotlin DSL file as a standalone script","Files like build.gradle.kts are Gradle build scripts written in Kotlin DSL; they are meant to be evaluated by Gradle, not executed as a generic Kotlin script.",[63,64],"If the file is named build.gradle.kts (or settings.gradle.kts), treat it as a Gradle build configuration.","Run it through Gradle as part of the project (not via kotlinc -script).",{"title":66,"description":67,"steps":68},"Script fails because Kotlin tooling isn’t installed or on PATH","Running a .kts file requires the Kotlin command-line compiler (kotlinc). If it is missing or not available in your shell PATH, the command won’t work.",[69,70,71],"Install the Kotlin command-line tools.","Verify kotlinc is available by running: kotlinc -version","Re-run the script using: kotlinc -script file.kts",[73,74,75],".kts files are executable code when run (for example with kotlinc -script). Only run scripts from sources you trust, because they can perform actions allowed by your user account.","Review the contents in a text editor before executing—especially if the file came from the internet or a repository you do not control.","Gradle-related .kts files (such as build.gradle.kts) influence build behavior; treating an untrusted project as safe can result in running untrusted build logic during a build.",[77,80,83,86],{"question":78,"answer":79},"What is a .kts file used for?","It is a Kotlin script source file. It can be run as a script with the Kotlin compiler, and it is also used for Gradle’s Kotlin DSL in files like build.gradle.kts.",{"question":81,"answer":82},"How do I run a .kts file?","Use the Kotlin command-line compiler in script mode: kotlinc -script file.kts (see Kotlin’s command-line compiler documentation).",{"question":84,"answer":85},"Is .gradle.kts the same as .kts?",".gradle.kts is a specialized use of Kotlin scripts for Gradle’s Kotlin DSL. It is still Kotlin-based, but it is intended to be interpreted by Gradle as build configuration.",{"question":87,"answer":88},"Does .kts have an official MIME type?","This should be checked against official registries. IANA’s media type registry is the authoritative place to verify standardized MIME types, and desktop mappings may also exist via freedesktop.org’s shared-mime-info.",[5],[],[92,98,103,109,115,121,127,133],{"ext":93,"name":94,"category":7,"categoryName":8,"popularity":95,"summary":96,"howToOs":97},"php","PHP script (PHP source code)",85,".php files typically contain PHP source code used on web servers to generate dynamic web pages and API responses. You can open them in a code editor, but they are usually executed by a web server (often via PHP-FPM) rather than “run” like a normal desktop app.",[13,14,15,16,17],{"ext":99,"name":100,"category":7,"categoryName":8,"popularity":95,"summary":101,"howToOs":102},"sql","SQL script (Structured Query Language)",".sql files contain SQL statements (queries, schema definitions, and data changes) that can be run by a database tool or opened as plain text for review and editing.",[13,14,15,16,17],{"ext":104,"name":105,"category":7,"categoryName":8,"popularity":106,"summary":107,"howToOs":108},"cs","C# source code file",80,".cs files contain C# source code used to build .NET applications and libraries. They are plain-text files typically edited in code editors and IDEs such as Visual Studio Code with C# tooling.",[13,14,15,16,17],{"ext":110,"name":111,"category":7,"categoryName":8,"popularity":112,"summary":113,"howToOs":114},"go","Go source file",78,".go files contain source code written in the Go (Golang) programming language. You can open them in code editors (for reading/editing) or build/run them with the Go toolchain.",[13,14,15,16,17],{"ext":116,"name":117,"category":7,"categoryName":8,"popularity":118,"summary":119,"howToOs":120},"tsx","TypeScript JSX (TSX) source file",75,".tsx is a TypeScript source code file that contains JSX syntax, commonly used with React-style UI components. You open it in a code editor (for viewing/editing) and build it with TypeScript tooling (for running in apps).",[13,14,15,16,17],{"ext":122,"name":123,"category":7,"categoryName":8,"popularity":124,"summary":125,"howToOs":126},"kt","Kotlin source file",72,".kt files contain Kotlin source code used to build Kotlin applications (including Android apps) and libraries. You typically open them in a code editor or IDE such as IntelliJ IDEA or Android Studio.",[13,14,15,16,17],{"ext":128,"name":129,"category":7,"categoryName":8,"popularity":130,"summary":131,"howToOs":132},"swift","Swift Source Code",70,".swift is a Swift programming language source file used to write apps and other software. You open it in code editors and IDEs such as Xcode or other text/code editors.",[13,14,15,16,17],{"ext":134,"name":135,"category":7,"categoryName":8,"popularity":136,"summary":137,"howToOs":138},"dart","Dart source code",65,".dart files contain source code written in the Dart programming language. You open them in a code editor/IDE or work with them using the Dart SDK tools.",[13,14,15,16,17],[140,143,146],{"label":141,"to":142},"Home","/",{"label":144,"to":145},"File Extension Index","/file-extension",{"label":147,"to":148},".KTS","/file-extension/kts","category-code","/category/code","Learn what .KTS files are, how to open them on every platform, common fixes, and security best practices.",[13,14,15,16,17],[154,157,160,163,166],{"os":13,"label":155,"to":156},"Open .KTS on Windows","/how-to/open-kts-on-windows",{"os":14,"label":158,"to":159},"Open .KTS on Mac","/how-to/open-kts-on-mac",{"os":15,"label":161,"to":162},"Open .KTS on Linux","/how-to/open-kts-on-linux",{"os":16,"label":164,"to":165},"Open .KTS on iOS","/how-to/open-kts-on-ios",{"os":17,"label":167,"to":168},"Open .KTS on Android","/how-to/open-kts-on-android",[54,60,66],[57,58],[],"code_runtime",[174,178],{"name":175,"description":176,"affiliateUrl":177},"Avast","Avast offers free and premium antivirus software that protects against viruses, malware, ransomware, and phishing. Scan files before opening them to ensure safety.","https://www.avast.com/lp-aff-consumer-store?expid=inf601",{"name":179,"description":180,"affiliateUrl":181},"Norton","Norton 360 delivers comprehensive antivirus protection, VPN, and identity theft monitoring. Scan files for threats before opening to keep your device secure.","http://buy.norton.com/aff_home?utm_campaign=en-ww_nor_n36_aff_nas_nau_nah_cj_nad_low:_sec_nat_mktc_norton_360"]