XML to Jetpack Compose Converter

VerifiedSafe

Convert Android XML layouts to idiomatic Jetpack Compose code. Handles layouts, widgets, attributes, styles, and resource references.

Sby Skills Guide Bot
DevelopmentIntermediate
7/22/2026
Claude CodeCursorCodex
#android#jetpack-compose#xml-migration#kotlin#ui

Recommended for

Automated summary

Converts Android XML layouts into idiomatic Jetpack Compose code by mapping containers, widgets, attributes, and resource references to composables and Modifier chains.

Strengths

  • Provides direct lookup tables for layouts (LinearLayout, FrameLayout, RecyclerView, ViewPager2) and common widgets
  • Explicitly flags that Modifier order matters and supplies a reference sequence
  • Enforces Compose good practices: Material 3, stateless composables, state hoisting, and a generated @Preview
  • Handles resource references (@string, @dimen, @color) and promotes extracting styles into theme values or reusable composables

Limitations

  • The skill body points to reference files (layouts.md, widgets.md, attributes.md) that are not included here, so the detailed mappings are missing
  • Does not cover dynamic XML logic: DataBinding/ViewBinding, RecyclerView adapters, animations, custom attributes, or custom views
  • Some mappings are approximations (ConstraintLayout, margins turned into Spacer) and need manual visual verification
When to use it

Use it when you need to migrate an existing Android XML layout file into an equivalent Compose composable.

When not to use it

Avoid it for screens heavily reliant on DataBinding, complex custom views, or non-trivial adapter logic that require a manual rewrite.

Security analysis

Safe
Quality score82/100

This is a pure documentation/instruction skill containing reference tables and an illustrative code example for XML-to-Compose conversion. It declares no tools, runs no scripts, makes no network calls, and touches no secrets or filesystem paths outside of mentioning optional reference markdown files. The example code is benign Kotlin/Compose UI code. There is no execution risk.

No concerns found

How this analysis is made

Examples

Convert a login layout
Convert this XML layout to Jetpack Compose: a vertical LinearLayout with padding 16dp containing an EditText for email, an EditText for password and a Button labelled @string/login. Use Material 3 and add a @Preview.
Migrate a list screen
Migrate this RecyclerView-based XML layout to Compose with LazyColumn, keeping the item layout as a separate composable and hoisting the click handler to the caller.
Fix attribute to modifier conversion
Convert this XML with layout_marginTop, background and padding attributes into a Compose composable, and explain the correct Modifier order for outer padding, background and inner padding.

name: xml-to-compose description: Convert Android XML layouts to Jetpack Compose. Use when asked to migrate XML layouts, convert views to composables, or help with Compose migration. Handles layouts, widgets, attributes, styles, and resource references.

XML to Jetpack Compose Converter

Convert Android XML layouts to idiomatic Jetpack Compose code.

Conversion Process

  1. Analyze the XML structure and identify root layout
  2. Map each view to its Compose equivalent
  3. Convert attributes to Modifier chains (order matters!)
  4. Handle resource references (@string, @dimen, @color)
  5. Extract styles into reusable composables or theme values

Quick Reference

Layouts

| XML | Compose | |-----|---------| | LinearLayout (vertical) | Column | | LinearLayout (horizontal) | Row | | FrameLayout | Box | | ConstraintLayout | Column/Row or ConstraintLayout (dependency) | | ScrollView | Column + Modifier.verticalScroll() | | RecyclerView | LazyColumn / LazyRow | | ViewPager2 | HorizontalPager |

Common Widgets

| XML | Compose | |-----|---------| | TextView | Text | | EditText | TextField / OutlinedTextField | | Button | Button | | ImageView | Image / AsyncImage (Coil) | | CheckBox | Checkbox | | Switch | Switch | | ProgressBar | CircularProgressIndicator / LinearProgressIndicator | | CardView | Card |

Modifier Order

Order matters! Follow this sequence:

  1. clickable / toggleable
  2. padding (outer)
  3. size / fillMaxWidth / weight
  4. background / clip
  5. border
  6. padding (inner)

Detailed Mappings

See reference files for complete mappings:

  • references/layouts.md — Layout containers
  • references/widgets.md — UI components
  • references/attributes.md — XML attributes to Modifiers

Output Guidelines

  1. Use Material 3 — Import from androidx.compose.material3
  2. Prefer built-in modifiers — Avoid custom implementations
  3. Handle nullability — XML allows null text, Compose needs defaults
  4. Extract dimensions — Use dimensionResource() or define in theme
  5. Keep composables stateless — Hoist state to caller
  6. Add Preview — Include @Preview function for each composable

Example

Input:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:padding="16dp">
    
    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/welcome"
        android:textSize="24sp"
        android:textStyle="bold"/>
        
    <Button
        android:id="@+id/action_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:text="@string/get_started"/>
</LinearLayout>

Output:

@Composable
fun WelcomeSection(
    onGetStartedClick: () -> Unit,
    modifier: Modifier = Modifier
) {
    Column(
        modifier = modifier
            .fillMaxWidth()
            .padding(16.dp)
    ) {
        Text(
            text = stringResource(R.string.welcome),
            fontSize = 24.sp,
            fontWeight = FontWeight.Bold
        )
        
        Spacer(modifier = Modifier.height(8.dp))
        
        Button(
            onClick = onGetStartedClick,
            modifier = Modifier.fillMaxWidth()
        ) {
            Text(text = stringResource(R.string.get_started))
        }
    }
}

@Preview(showBackground = true)
@Composable
private fun WelcomeSectionPreview() {
    WelcomeSection(onGetStartedClick = {})
}

Key conversions:

  • match_parent → fillMaxWidth() / fillMaxHeight()
  • wrap_content → default (no modifier needed)
  • layout_marginTop → Spacer between elements
  • Click listeners → lambda parameters
  • IDs → not needed (state hoisting instead)

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/xml-to-jetpack-compose-converter-mrwakf9d/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/xml-to-jetpack-compose-converter-mrwakf9d' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/xml-to-jetpack-compose-converter-mrwakf9d/download' --output '.skill-downloads/xml-to-jetpack-compose-converter-mrwakf9d/SKILL.md.part' && mv '.skill-downloads/xml-to-jetpack-compose-converter-mrwakf9d/SKILL.md.part' '.skill-downloads/xml-to-jetpack-compose-converter-mrwakf9d/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Original excerpt: Quick Reference

Layouts

XMLCompose
LinearLayout (vertical)Column
LinearLayout (horizontal)Row
FrameLayoutBox
ConstraintLayoutColumn/Row or ConstraintLayout (dependency)
ScrollViewColumn + Modifier.verticalScroll()
RecyclerViewLazyColumn / LazyRow
ViewPager2HorizontalPager

Common Widgets

XMLCompose
TextViewText
EditTextTextField / OutlinedTextField
ButtonButton
ImageViewImage / AsyncImage (Coil)
CheckBoxCheckbox
SwitchSwitch
ProgressBarCircularProgressIndicator / LinearProgressIndicator
CardViewCard

Modifier Order

Order matters! Follow this sequence:

  1. clickable / toggleable
  2. padding (outer)
  3. size / fillMaxWidth / weight
  4. background / clip
  5. border
  6. padding (inner)

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/xml-to-jetpack-compose-converter-mrwakf9d/SKILL.md' && test -s '.skill-downloads/xml-to-jetpack-compose-converter-mrwakf9d/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/xml-to-compose' && cp -R '.skill-downloads/xml-to-jetpack-compose-converter-mrwakf9d' '.claude/skills/xml-to-compose'

Cursor
test -f '.skill-downloads/xml-to-jetpack-compose-converter-mrwakf9d/SKILL.md' && test -s '.skill-downloads/xml-to-jetpack-compose-converter-mrwakf9d/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/xml-to-compose' && cp -R '.skill-downloads/xml-to-jetpack-compose-converter-mrwakf9d' '.cursor/skills/xml-to-compose'

Codex
test -f '.skill-downloads/xml-to-jetpack-compose-converter-mrwakf9d/SKILL.md' && test -s '.skill-downloads/xml-to-jetpack-compose-converter-mrwakf9d/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/xml-to-compose' && cp -R '.skill-downloads/xml-to-jetpack-compose-converter-mrwakf9d' '.agents/skills/xml-to-compose'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/xml-to-jetpack-compose-converter-mrwakf9d'

openskills read 'xml-to-jetpack-compose-converter-mrwakf9d'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/xml-to-jetpack-compose-converter-mrwakf9d/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills