The naming table

IdentifierConventionExample
Packageslowercase, no underscoresorg.example.project
Classes and objectsUpperCamelCaseDeclarationProcessor
FunctionscamelCase starting lowercaseprocessDeclarations()
Properties and local variablescamelCase starting lowercasedeclarationCount
ConstantsSCREAMING_SNAKE_CASEMAX_COUNT
Backing propertiesunderscore prefix_elementList
Files with one classthe class name plus .ktDeclarationProcessor.kt

What counts as a constant

SCREAMING_SNAKE_CASE is for const val properties and for top-level or object val properties with no custom getter that hold deeply immutable data. A top-level val that holds a mutable collection or an object with behavior stays camelCase. A property that refers to a singleton object can use the object naming style, as in val PersonComparator. Enum constants may be either SCREAMING_SNAKE_CASE or UpperCamelCase.

Acronyms: two letters vs three or more

A two-letter acronym keeps both capitals: IOStream. A longer one capitalizes only its first letter: XmlFormatter, HttpInputStream.

Functions that look like classes

Two kinds of functions are named like classes. A factory function may share the name of the abstract type it returns, as in fun Foo(): Foo. And @Composable functions that return Unit use UpperCamelCase, as in TabHeader.

Test names may contain spaces

In tests only, you can name a method with backticks and spaces, as in fun `ensure everything works`(), or use underscores. Kotlin notes that names with spaces are only supported on Android from API level 30.

Package and file names

Multi-word package names are discouraged; if you need one, join the words or use camelCase, as in org.example.myProject. A file holding several declarations gets a descriptive UpperCamelCase name, such as ProcessDeclarations.kt; avoid meaningless names like Util.

Converting names with Transform Case

Our snake_case, camelCase, PascalCase and CONSTANT_CASE converters treat an acronym as one word, so HTTP server error becomes HttpServerError and http_server_error. For three-letter and longer acronyms that matches Kotlin. For a two-letter acronym, put both capitals back: IoStream becomes IOStream.

Naming conventions in other languages: Python, Java, C#, Go (Golang), Rust, Swift, Dart, PHP. All side by side: 20 languages compared.

Sources

Questions

Is it XMLParser or XmlParser in Kotlin?
XmlParser. Kotlin capitalizes only the first letter of acronyms longer than two letters; two-letter acronyms keep both capitals, as in IOStream.

When does a Kotlin val use SCREAMING_SNAKE_CASE?
When it's a const val, or a top-level or object val with no custom getter holding deeply immutable data.

Can Kotlin test names have spaces?
Yes, in backticks, but only in tests. On Android this needs API level 30 or later.