Skip to content

MBMyBatis Converter

Loading...

MyBatis is the most widely used SQL mapper framework in the Java ecosystem. MyBatis queries contain parameter bindings like #{param} and ${param} along with dynamic tags like <if>, <where>, and <choose>, making it hard to run them directly in a DB client. This tool evaluates dynamic tags based on parameter values to produce executable SQL, and can also generate MyBatis XML mapper templates from plain SQL.

How to Use

  1. 1
    Select Tab

    Use 'MyBatis โ†’ SQL' to evaluate dynamic tags and replace parameters with actual values. Use 'SQL โ†’ MyBatis XML' to convert plain SQL into MyBatis XML mapper format.

  2. 2
    Enter Query

    Paste your MyBatis/iBatis query or plain SQL into the input area. #{param} is auto-detected as MyBatis 3 and #param# as iBatis 2.

  3. 3
    Set Parameters (MyBatis โ†’ SQL)

    Configure the type (string/number) and value for each detected parameter. Dynamic tag conditions are evaluated automatically โ€” blocks whose condition is not met are removed from the output.

  4. 4
    Review & Copy

    Review the converted SQL or MyBatis XML and copy it to your clipboard.

Tips

  • ๐Ÿ’กMyBatis 3 dynamic tags supported: <if test="x != null">, <where>, <set>, <choose>/<when>/<otherwise>, <trim>, <foreach>.
  • ๐Ÿ’กiBatis 2 dynamic tags supported: <isNotEmpty>, <isEmpty>, <isNotNull>, <isNull>, <isEqual>, <isGreaterThan>, etc., and <dynamic prepend="WHERE">.
  • ๐Ÿ’กFilling in a parameter value includes its condition block; leaving it empty removes the block. <![CDATA[...]]> wrappers are also stripped automatically.
  • ๐Ÿ’ก#{param} uses PreparedStatement binding (values are quoted). ${param} is string substitution (inserted as-is).
  • ๐Ÿ’กAll processing happens in your browser, so sensitive queries are never sent to a server.

FAQ

Q. Why do I need to convert MyBatis log parameters?
A. MyBatis logs show SQL with ? placeholders and lists parameter values separately. This tool substitutes the actual values back in, producing executable SQL you can run directly in a database client.
Q. What parameter types are supported?
A. String, Number, Boolean, null, and Date types are supported. Strings are automatically quoted, and null is converted to the SQL NULL keyword.
Q. Why does MyBatis use Prepared Statements?
A. Prepared Statements (the #{} syntax) prevent SQL injection attacks and allow the database to cache the query execution plan for better performance.

DevHelper

ยฉ 2026. All rights reserved.