IFSC based bank detail finder using core java

IFSC Code Bank Detail Finder Using Core Java (Complete Guide 2026)

IFSC Code Bank Detail Finder Using Core Java

In this tutorial, you will build a desktop application in Core Java that takes an IFSC code as input and displays the corresponding bank details — bank name, branch, address, city, district, state, and more.

We will use Java Swing for the UI, the free Razorpay IFSC API to fetch data, and Google Gson to parse the JSON response into a Java object. No Spring Boot, no database — just plain Java.

What is an IFSC Code?

IFSC (Indian Financial System Code) is an 11-character alphanumeric code assigned by the Reserve Bank of India to identify every bank branch in the country. It is used for electronic fund transfers such as NEFT, RTGS, and IMPS.

Format: ABCD0123456

  • First 4 characters — Bank code (e.g., HDFC, ICIC, SBIN)
  • 5th character — Always 0 (reserved for future use)
  • Last 6 characters — Branch code

Every IFSC uniquely identifies one branch of one bank, which is why it is the key used in this project.

What You Will Build

A simple Swing desktop application that:

  • Accepts an IFSC code in a text field
  • Calls the Razorpay IFSC API on button click
  • Parses the JSON response into a Java Bank object
  • Displays the bank name, address, city, branch, district, and state

Requirements

  • JDK 8 or later (Java 11+ recommended)
  • Maven (for dependency management) or manual JAR download
  • Google Gson 2.8.5 or later
  • IDE: IntelliJ IDEA, Eclipse, or VS Code
  • Internet connection (to call the API)

Project Structure

The project follows a clean package structure separating the model, service, and UI layers.

Packages used:

  • com.example.model — Bank POJO
  • com.example.service — BankService (API caller)
  • com.example.ui — MainPage (Swing UI)

Maven Dependency (Gson)

Add the following dependency in your pom.xml. Gson converts the JSON response from the API into a Java object automatically.

<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.8.5</version>
</dependency>

Note: If you are not using Maven, download the gson-2.8.5.jar file and add it to your project's build path manually.

Bank.java — Model Class

The Bank class is a Plain Old Java Object (POJO) that maps every field returned by the Razorpay IFSC API. Each field has a getter and setter so that Gson can populate it during JSON parsing.

package com.example.model;

public class Bank {
    private String DISTRICT;
    private Boolean RTGS;
    private String SWIFT;
    private Boolean UPI;
    private String CONTACT;
    private Boolean NEFT;
    private String CITY1;
    private String MICR;
    private Boolean IMPS;
    private String PHONE;
    private String ADDRESS;
    private String BRANCH;
    private String CITY2;
    private String CITY;
    private String STATE;
    private String CENTRE;
    private String BANK;
    private String BANKCODE;
    private String IFSC;

    public String getDISTRICT() {
        return DISTRICT;
    }

    public void setDISTRICT(String dISTRICT) {
        DISTRICT = dISTRICT;
    }

    public Boolean getRTGS() {
        return RTGS;
    }

    public void setRTGS(Boolean rTGS) {
        RTGS = rTGS;
    }

    public String getSWIFT() {
        return SWIFT;
    }

    public void setSWIFT(String sWIFT) {
        SWIFT = sWIFT;
    }

    public Boolean getUPI() {
        return UPI;
    }

    public void setUPI(Boolean uPI) {
        UPI = uPI;
    }

    public String getCONTACT() {
        return CONTACT;
    }

    public void setCONTACT(String cONTACT) {
        CONTACT = cONTACT;
    }

    public Boolean getNEFT() {
        return NEFT;
    }

    public void setNEFT(Boolean nEFT) {
        NEFT = nEFT;
    }

    public String getCITY1() {
        return CITY1;
    }

    public void setCITY1(String cITY1) {
        CITY1 = cITY1;
    }

    public String getMICR() {
        return MICR;
    }

    public void setMICR(String mICR) {
        MICR = mICR;
    }

    public Boolean getIMPS() {
        return IMPS;
    }

    public void setIMPS(Boolean iMPS) {
        IMPS = iMPS;
    }

    public String getPHONE() {
        return PHONE;
    }

    public void setPHONE(String pHONE) {
        PHONE = pHONE;
    }

    public String getADDRESS() {
        return ADDRESS;
    }

    public void setADDRESS(String aDDRESS) {
        ADDRESS = aDDRESS;
    }

    public String getBRANCH() {
        return BRANCH;
    }

    public void setBRANCH(String bRANCH) {
        BRANCH = bRANCH;
    }

    public String getCITY2() {
        return CITY2;
    }

    public void setCITY2(String cITY2) {
        CITY2 = cITY2;
    }

    public String getCITY() {
        return CITY;
    }

    public void setCITY(String cITY) {
        CITY = cITY;
    }

    public String getSTATE() {
        return STATE;
    }

    public void setSTATE(String sTATE) {
        STATE = sTATE;
    }

    public String getCENTRE() {
        return CENTRE;
    }

    public void setCENTRE(String cENTRE) {
        CENTRE = cENTRE;
    }

    public String getBANK() {
        return BANK;
    }

    public void setBANK(String bANK) {
        BANK = bANK;
    }

    public String getBANKCODE() {
        return BANKCODE;
    }

    public void setBANKCODE(String bANKCODE) {
        BANKCODE = bANKCODE;
    }

    public String getIFSC() {
        return IFSC;
    }

    public void setIFSC(String iFSC) {
        IFSC = iFSC;
    }
}

Tip: If you use Lombok in your project, you can replace all the getters and setters with a single @Data annotation. Since this tutorial targets beginners, we have kept the explicit getters and setters.

BankService.java — API Caller

BankService is responsible for calling the Razorpay IFSC API and converting the JSON response into a Bank object. It uses HttpURLConnection (built into the JDK) and Gson for parsing.

package com.example.service;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

import com.example.model.Bank;
import com.google.gson.Gson;

public class BankService {

    public Bank getBankDetailAPi(String ifsc) {
        try {
            String api = "https://ifsc.razorpay.com/" + ifsc;
            URL url = new URL(api);
            HttpURLConnection hr = (HttpURLConnection) url.openConnection();
            InputStream inputStream = hr.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));

            String line = br.readLine();
            StringBuffer sb = new StringBuffer();

            while (line != null) {
                sb.append(line).append("\n");
                line = br.readLine();
            }

            System.out.println(sb.toString());
            return new Gson().fromJson(sb.toString(), Bank.class);

        } catch (Exception e) {
            System.out.println(e);
        }
        return null;
    }
}

Why this works: The Razorpay IFSC API accepts an IFSC as part of the URL path and returns a JSON object. Gson maps the JSON keys directly to the fields in the Bank class — no manual parsing needed.

MainPage.java — Swing UI

MainPage builds the Swing window with a text field, a Search button, and a text area to display the results. It wires up the button click to call BankService.

package com.example.ui;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import com.example.model.Bank;
import com.example.service.BankService;

public class MainPage {
    private BankService bankService = new BankService();

    public MainPage() {
        JFrame frame = new JFrame("IFSC BASED BANK DETAIL FINDER");
        frame.setSize(600, 500);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel panel = new JPanel();
        panel.setBackground(new Color(10, 56, 67));
        panel.setLayout(null);

        JTextField textField = new JTextField();
        textField.setBounds(100, 100, 300, 35);
        panel.add(textField);

        JButton button = new JButton("Search");
        button.setBounds(410, 100, 100, 35);
        panel.add(button);

        JTextArea textArea = new JTextArea();
        textArea.setFont(new Font("", Font.BOLD, 12));
        JScrollPane jp = new JScrollPane(textArea);
        jp.setBounds(100, 160, 410, 200);
        panel.add(jp);

        frame.add(panel);
        frame.setVisible(true);

        button.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                Bank bank = bankService.getBankDetailAPi(textField.getText());

                if (bank != null) {
                    String result = "Bank Name : " + bank.getBANK() + "\n"
                            + "Bank Address : " + bank.getADDRESS() + "\n"
                            + "Bank City : " + bank.getCITY() + "\n"
                            + "Bank Branch : " + bank.getBRANCH() + "\n"
                            + "Bank District : " + bank.getDISTRICT() + "\n"
                            + "Bank State : " + bank.getSTATE() + "\n";
                    textArea.setText(result);
                } else {
                    textArea.setText("Please check your IFSC code");
                }
            }
        });
    }

    public static void main(String[] args) {
        new MainPage();
    }
}

UI Layout: The panel uses null layout with absolute bounds, which is fine for a simple demo. For production Swing apps, use GridBagLayout or GroupLayout for responsiveness.

Output Screens

Below are the output screenshots of the application:



How It Works (Step-by-Step)

  1. User enters an IFSC code into the text field (e.g., HDFC0001234).
  2. Search button click triggers BankService.getBankDetailAPi(ifsc).
  3. HTTP request is sent to https://ifsc.razorpay.com/{IFSC} using HttpURLConnection.
  4. JSON response is read line by line into a StringBuffer.
  5. Gson parses the JSON string into a Bank object using new Gson().fromJson(json, Bank.class).
  6. UI update — if the object is not null, the fields are displayed in the text area. Otherwise, an error message is shown.

Customization Ideas

  • Add a Clear button to reset the input and output.
  • Show additional fields like MICR, SWIFT, NEFT, RTGS, IMPS, UPI.
  • Add a Lookup History panel that remembers recent searches.
  • Replace the text area with a JTable for a tabular layout.
  • Add offline support by storing IFSC data in a local SQLite database.

Frequently Asked Questions

How do I find bank details from an IFSC code in Java?

You can use a free public API such as the Razorpay IFSC API (https://ifsc.razorpay.com/{IFSC}). Open an HTTP connection with HttpURLConnection, read the JSON response, and parse it with Gson into a Java model class such as Bank.

What is an IFSC code?

IFSC stands for Indian Financial System Code. It is an 11-character alphanumeric code that uniquely identifies every bank branch in India for NEFT, RTGS, and IMPS transactions. The first 4 characters represent the bank, the 5th is 0, and the last 6 identify the branch.

Which library is used to parse JSON in this project?

This project uses the Google Gson library. Gson converts the JSON response from the Razorpay IFSC API directly into a Java object using new Gson().fromJson(jsonString, Bank.class).

Is the Razorpay IFSC API free to use?

Yes. The Razorpay IFSC API is publicly available and free for basic lookups. It returns bank details such as bank name, branch, address, city, state, MICR, and supported payment modes (NEFT, RTGS, IMPS, UPI).

Can I build this project without an API?

Yes, but you would need to maintain your own IFSC database. Using an API is recommended because it is always up to date and requires no storage. If you must work offline, download the RBI IFSC dataset and query it locally.

Conclusion

In this tutorial, you built a complete IFSC code bank detail finder using Core Java, Swing, and Gson. You learned how to make an HTTP request, parse JSON into a Java object, and display the result in a desktop UI — all without any framework.

This project is a great starting point for beginner Java developers who want to understand real-world API integration. Try extending it with the ideas above, or rebuild it using JavaFX for a more modern look.

Related topics: Java HTTPURLConnection, Gson JSON Parsing, Java Swing Tutorial, IFSC API, Java REST Client, Java Desktop Applications

No comments: