The string template was a preview feature in Java 21 and Java 22, and has been withdrawn for further redesign. In other words, this feature never existed in mainline Java (you needed to enable preview features to use it), and now with the release of Java 23, it doesn't exist at all.

If you get recommendations from IntelliJ to use string templates, you either need to update IntelliJ (it shouldn't suggest this at all for Java 23), or possibly you have set your language level to "21 (Preview)" or "22 (Preview)", instead of normal (non-preview) language level "21", "22" or "23". In other words, go to File, Project Structure, and on Project check the language level, and double-check for individual Modules (on their "Sources" tab).

As an aside, recent Java versions already optimize string concatenation like "The capital city of " + index + " is " pretty well by replacing it with a low-level form of templating in the compiled bytecode.

Answer from Mark Rotteveel on Stack Overflow
๐ŸŒ
Oracle
docs.oracle.com โ€บ en โ€บ java โ€บ javase โ€บ 21 โ€บ language โ€บ string-templates.html
4 String Templates
January 16, 2025 - A template processor combines the literal text in the template with the values of the embedded expressions to produce a result. See the StringTemplate interface in the Java SE API specification for more information.
๐ŸŒ
OpenJDK
openjdk.org โ€บ jeps โ€บ 430
JEP 430: String Templates (Preview)
September 17, 2021 - When a template expression is evaluated ... the result of evaluating the template expression, is often a String โ€” though not always. STR is a template processor defined in the Java Platform....
Discussions

java - Why is String template not available - Stack Overflow
String Templates were a preview feature of Java 21/22 and were removed in Java 23. The reason given was: After some experience with the prototype, it became clear that the processor-centric nature of the proposed design was confusing to users and lacked the desired compositionality. More on stackoverflow.com
๐ŸŒ stackoverflow.com
There will be no String Template in JDK 23.
wow. It's interesting that Brian Goetz recently said he was ready to finalize the feature and move on, and all the complaints were nothing they hadn't anticipated and discussed extensively. They had the JEP submitted to finalize this for Java 22 and they held off to a second unchanged preview, and then were going to finalize for Java 23, and now, even Goetz is ready to move the whole thing back to a complete redesign. As a Java dev I'd rather get this later with a better design than earlier with a less perfect design. It is interesting how close the existing design was to being finalized. The preview system works :) More on reddit.com
๐ŸŒ r/java
131
122
April 6, 2024
String replacement in java, similar to a velocity template - Stack Overflow
Java 23 withdrew/removed the feature. See the string templates proposal (JEP 430) here. More on stackoverflow.com
๐ŸŒ stackoverflow.com
JEP: String Templates (Final) for Java 22
I have read the explanation by various members of the OpenJDK team as to why that syntax was chosen and I still don't understand it. Even Brian's explanation, which otherwise gets right through to me even on more complex topics, did not really clarify it for me. He says choosing ${} would have made all the existing Strings a template if they contain ${} with a valid variable in the same scope, which breaks compatibility. But I don't know what I am missing to not see the breakage. For an existing String literal having a ${...} does not make it into a template that will be processed. You have to explicitly invoke STR. on that to process it as a template. Else if will be just like any other String with no interpolation. STR. is a completely new feature and is illegal in prior versions so I don't see how this breaks compatibility. Even if you had a variable named STR in existing code, it is illegal to do STR."some str literal". I guess it is too late now. More on reddit.com
๐ŸŒ r/java
133
72
October 1, 2023
๐ŸŒ
OpenJDK
openjdk.org โ€บ jeps โ€บ 465
JEP 465: String Templates (Third Preview)
January 9, 2024 - When a template expression is evaluated ... the result of evaluating the template expression, is often a String โ€” though not always. STR is a template processor defined in the Java Platform....
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java string โ€บ string templates in java
String Templates in Java | Baeldung
July 7, 2025 - Java provides some out-of-the-box template processors. The STR Template Processor performs string interpolation by iteratively replacing each embedded expression of the provided template with the stringified value of that expression.
๐ŸŒ
Belief Driven Design
belief-driven-design.com โ€บ looking-at-java-21-string-templates-c7cbc
Looking at Java 21: String Templates | belief driven design
June 20, 2023 - As String -> String templates are most likely the default use case for String templates, the template processor STR is automagically imported into every Java source file.
๐ŸŒ
Oracle
docs.oracle.com โ€บ en โ€บ java โ€บ javase โ€บ 21 โ€บ docs โ€บ api โ€บ java.base โ€บ java โ€บ lang โ€บ StringTemplate.Processor.html
StringTemplate.Processor (Java SE 21 & JDK 21)
October 20, 2025 - Constructs a result based on the template fragments and values in the supplied stringTemplatePREVIEW object. ... Processing of a StringTemplatePREVIEW may include validation according to the particular facts relating to each situation. The E type parameter indicates the type of checked exception ...
๐ŸŒ
JetBrains
blog.jetbrains.com โ€บ idea โ€บ 2023 โ€บ 11 โ€บ string-templates-in-java-why-should-you-care
String Templates in Java - why should you care? | The IntelliJ IDEA Blog
November 27, 2023 - It is a predefined template processor defined in the Java API. Template: Everything within " " or """ """ is a template Embedded expressions: Each occurrence of dynamic data, such as, \{qty} is embedded expressions.
Find elsewhere
๐ŸŒ
OpenJDK
openjdk.org โ€บ jeps โ€บ 459
JEP 459: String Templates (Second Preview)
August 14, 2023 - When a template expression is evaluated ... the result of evaluating the template expression, is often a String โ€” though not always. STR is a template processor defined in the Java Platform....
๐ŸŒ
How to do in Java
howtodoinjava.com โ€บ home โ€บ java 21 string templates
Java 21 String Templates (with Examples)
July 30, 2024 - Now let us go through some important concepts that we must know when writing the new template strings. A template processor is part of the language itself. It is a โ€˜public static finalโ€˜ field that is automatically imported into every Java ...
๐ŸŒ
Medium
medium.com โ€บ @viraj_63415 โ€บ java-21-string-templates-79fd908f30ff
Java String Templates โ€” A Better Interpolation | by Viraj Shetty | Medium
June 19, 2024 - Template Processor (STR) โ€” The Template Processor is a class implementing StringTemplate.Processor interface and is directly responsible for the conversion of String Template to the final output.
๐ŸŒ
Oracle
docs.oracle.com โ€บ en โ€บ java โ€บ javase โ€บ 21 โ€บ docs โ€บ api โ€บ java.base โ€บ java โ€บ lang โ€บ StringTemplate.html
StringTemplate (Java SE 21 & JDK 21)
January 20, 2026 - Evaluation of a template expression first produces an instance of StringTemplatePREVIEW, representing the right hand side of the template expression, and then passes the instance to the template processor given by the template expression.
๐ŸŒ
HappyCoders.eu
happycoders.eu โ€บ java โ€บ string-templates
String Templates in Java
June 12, 2025 - STR is the name of a so-called template processor (more precisely: a constant of type StringTemplate.Processor automatically imported into every Java file). A template processor defines how template text and placeholders are combined.
๐ŸŒ
InfoQ
infoq.com โ€บ news โ€บ 2023 โ€บ 04 โ€บ java-gets-a-boost-with-string
Java Gets a Boost with String Templates: Simplifying Code and Improving Security - InfoQ
April 28, 2023 - A template processor is an object that provides the functional interface ValidatingProcessor, and its class implements the single abstract method of ValidatingProcessor, which takes a StringTemplate and returns an object.
๐ŸŒ
GitHub
github.com โ€บ forax โ€บ string-template
GitHub - forax/string-template: Java 21 adds the concept of String template, this is a repository of examples and perf tests of this feature ยท GitHub
There is a special syntax to invoke a template processor that does two things, first, from a string with some values escaped in between '(' and ')' creates a 'templated string' then calls a template processor with that 'templated string'.
Author ย  forax
๐ŸŒ
Reddit
reddit.com โ€บ r/java โ€บ jep: string templates (final) for java 22
r/java on Reddit: JEP: String Templates (Final) for Java 22
October 1, 2023 - The question was asked in the mailing ... template processors became mandatory. The arguments were (no order): Embed other languages such as JavaScript without fear of conflict. No conflict with existing templating libraries. The language already has an escaping mechanism for string ...
๐ŸŒ
JVM Advent
javaadvent.com โ€บ home โ€บ beyond the basics: elevating java string handling with custom template processors
Beyond the Basics: Elevating Java String Handling with Custom Template Processors - JVM Advent
December 23, 2023 - Java 21 has introduced a groundbreaking feature called String Templates. This new feature, which is part of JEP 430, changes the way Java handles strings by combining literal text with dynamic expressions and template processors.